首页 > 代码库 > ImportError: cannot import name patterns
ImportError: cannot import name patterns
The use of patterns is deprecated in Django1.10. Therefore do not import ‘patterns‘ and your url pattern should be as follows:
from django.conf.urls import include, url
urlpatterns=[
url(r‘^admin/‘, include(admin.site.urls)),
url(........),
]
这个特性在1.9就声明了deprecated. 1.10正式移除了。使用 django 1.10 需要改用 django.conf.urls.url() 示范代码:
1
2
3
4
5
6
7
8
9
10
|
from django.conf.urls import url from . import views urlpatterns = [ url(r ‘^articles/2003/$‘ , views.special_case_2003), url(r ‘^articles/([0-9]{4})/$‘ , views.year_archive), url(r ‘^articles/([0-9]{4})/([0-9]{2})/$‘ , views.month_archive), url(r ‘^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$‘ , views.article_detail), ] |
ImportError: cannot import name patterns
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。