views:

61

answers:

2

Hi, all.

I have set up a url mapping that goes like this:

(r'enroll/$', 'enroll')

In my development environment this mapping is used when I visit '/enroll/'.

But in the production environment, the Django application is under '/activity/' and '/activity/enroll/' should be used.

Please tell me how do I get the correct url in both cases.

Thanks in advance.

+3  A: 

django.core.urlresolvers.reverse() or {% url %} can be used to turn a view reference or named urlconf into a URL suitable for output.

Ignacio Vazquez-Abrams
+3  A: 

I would suggest doing whatever you can to get your prod and dev as identical as possible, however if thats not possible you could use separate urlpatterns for the development environment.

Assuming you have a settings.DEBUG set, try the following:

extra_patterns = patterns('',
    (r'enroll/$', 'enroll'),
)

if settings.DEBUG:
    urlpatterns = patterns('', (r'^', include(extra_patterns)))
else:
    urlpatterns = patterns('', (r'^activity/', include(extra_patterns)))
lojack
Thx. Maybe I should start a new question and ask about how to get my prod and dev as identical as possible.
Satoru.Logic