python venv - Why is Django development server bringing my app under another app's address? -
after going through django project's tutorial on creating polling app, named polls, started own project on same virtual environment, under name. now, did in new app under the index view, still being shown @ http://127.0.0.1:8000/polls/ should @ http://127.0.0.1:8000/mynewproject/
i need on correcting this, or fact on 1 virtual environment, can work on 1 django project? , second question, should setting each project on different virtual envs?
first answer:
first wan mention these 2 things
- it doesn't matters how many projects there in virtual environment each can handled different different
manage.py
. - and each project runs on different addresses if single app won't run on different addresses (until manually).
as mentioned here had created app inside same project this
project -- manage.py -- project -- -- settings.py -- -- urls.py <<--- main url pattern file whole project -- -- wsgi.py -- app1 -- -- views.py -- -- models.py -- -- urls.py <<-- specific urls pattern file app1 (optional) -- -- others -- app2 -- -- views.py -- -- models.py -- -- urls.py <<-- specific urls pattern file app2 (optional) -- -- others
so if register urlpatterns every particular apps like
from django.conf.urls import url . import views urlpatterns = [ url(r'^home/$',views.home, name = "app_home"), ]
and
from django.conf.urls import url . import views urlpatterns = [ url(r'^home/$',views.home, name = "app_home"), ]
then have include both of these urls.py
files in projects main urls.py
this
from django.conf.urls import url, include urlpatterns = [ url(r'^app1/', include('app1.urls')), url(r'^app2/', include('app2.urls')), ]
or if don't wanna go this
can register both url patterns
in main urls.py
from django.conf.urls import url, include django.contrib import admin
urlpatterns = [ url(r'^app1/home', app1.views.home), url(r'^app2/home', app2.views.home), ]
so, it, have deal urls.py
files.
second answer: can create multiple projects in single virtual environment. configurations packages , versions stays same all. if make changes there (by upgrading, degrading, installing or uninstalling) affect projects inside virtual env.
Comments
Post a Comment