tmaster
tmaster

Reputation: 9655

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:

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?

Upvotes: 4

Views: 1072

Answers (1)

Iain Shelvington
Iain Shelvington

Reputation: 32294

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.

Upvotes: 9

Related Questions