Login

Url overrides and concurrent site versions

Author:
henrikv
Posted:
March 8, 2007
Language:
Python
Version:
Pre .96
Score:
0 (after 0 ratings)

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.

  1. make separate copies of settings_staging.py and urls_staging.py in the project dir.
  2. Change SITE_ID and ROOT_URLCONF in settings_staging.py
  3. Make extra include lines in the projects urls_staging.py like the example.
  4. 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

  1. Template tag - list punctuation for a list of items by shapiromatron 11 months, 2 weeks ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months, 3 weeks ago
  3. Serializer factory with Django Rest Framework by julio 1 year, 6 months ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 7 months ago
  5. Help text hyperlinks by sa2812 1 year, 7 months ago

Comments

Please login first before commenting.