使用django.conf.urls.patterns
与仅使用网址列表有什么好处?
例如
之间有什么区别urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
]
vs
urlpatterns = patterns(
'',
url(r'^admin/', include(admin.site.urls)))
答案 0 :(得分:7)
你应该使用一个列表,因为从版本1.8开始, patterns()是deprecated,并且将在1.10中删除:
def patterns(prefix, *args):
warnings.warn(
'django.conf.urls.patterns() is deprecated and will be removed in '
'Django 1.10. Update your urlpatterns to be a list of '
'django.conf.urls.url() instances instead.',
RemovedInDjango110Warning, stacklevel=2
)