Reputation: 2673
Why is it in some urls.py
files you see url(..)
and in others you see (..)
.
For example
urlpatterns = patterns('',
url('hello','article.view.hello')
)
and in others i see :
urlpatterns = patterns('',
('article/', include('article.urls'))
)
Upvotes: 0
Views: 63
Reputation: 49012
The use of patterns()
makes the use of url()
optional. Going forward, however, patterns
will be deprecated and you will have to always use url
. See this ticket:
The other thing that
patterns
provides besides the prefix parameter is automatically wrapping plain tuples inurlpatterns
inurl()
. I think removing this and forcing usage ofurl()
will be a good cleanup.
So you should get in the habit of always using url
.
Upvotes: 1
Reputation: 9767
Thank you for clarification with your edit:
But usage of url
is purely for convenience (but will be required in django 2.0). You can see the check here:
https://github.com/django/django/blob/master/django/conf/urls/init.py#L55
Upvotes: 0