Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

url

django

So in Django the two lines of url code below work the same:

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

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

like image 714
tmaster Avatar asked Jan 15 '23 23:01

tmaster


1 Answers

There is no difference whatsoever. Have a look at the patterns function in django.conf.urls.__init__.py, if your url is a list or tuple then it is wrapped up by the url function anyway before being appended to the list of available patterns.

like image 62
Iain Shelvington Avatar answered Jan 26 '23 02:01

Iain Shelvington