, 'enroll') In my development environment, this mapping is ...">

How to get Django url correctly?

I set a url that looks like this:

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

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

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

Please tell me how to get the correct URL in both cases.

Thanks in advance.

+3
source share
2 answers

I would suggest doing everything possible so that your product and developer are as identical as possible, however, if this is not possible, you can use separate URLs for the development environment.

, .DEBUG, :

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

if settings.DEBUG:
    urlpatterns = patterns('', (r'^', include(extra_patterns)))
else:
    urlpatterns = patterns('', (r'^activity/', include(extra_patterns)))
+3

Source: https://habr.com/ru/post/1743271/


All Articles