What is the difference between url () and tuple for urlpatterns in Django?

So, in Django, the two lines of URL code below work the same way:

urlpatterns = patterns('', url(r'^login/$', 'django.contrib.auth.views.login'), (r'^login/$', 'django.contrib.auth.views.login') ) 

AFAIK, the only difference is that I can define name='login' , so I can use it to reverse url. But are there any other differences besides this?

+4
source share
1 answer

There is no difference. Look at the patterns function in django.conf.urls.__init__.py , if your url is list or tuple , then it still ends with the url function before joining the list of available patterns.

+8
source

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


All Articles