If you want to run multiple versions of a site from the same project IE a staging version and the live one, you need two settings and urlconf files.
- make separate copies of settings_staging.py and urls_staging.py in the project dir.
- Change SITE_ID and ROOT_URLCONF in settings_staging.py
- Make extra include lines in the projects urls_staging.py like the example.
- Add urls_staging.py to applications where you need extra urls. Make them just like you would normally do urls.py
Thanks to ronny for suggesting the double entries in urlconf.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # in the project urls_staging.py
urlpatterns = patterns('',
(r'^about/', include('live.about.urls_staging')),
(r'^about/', include('live.about.urls')),
(r'^places/', include('live.place.urls.places_staging')),
(r'^places/', include('live.place.urls.places')),
(r'^comments/', include('live.place.urls.comments_staging')),
(r'^comments/', include('live.place.urls.comments')),
(r'^users/', include('live.users.urls_staging')),
(r'^users/', include('live.users.urls')),
(r'^admin/', include('django.contrib.admin.urls')),
)
# in the app urls_staging.py
from django.conf.urls.defaults import *
urlpatterns = patterns('live.users.views.account',
(r'^account$', 'my_account'),
(r'^account/friends$', 'friends'),
)
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 11 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 6 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 7 months ago
- Help text hyperlinks by sa2812 1 year, 7 months ago
Comments
Please login first before commenting.