ImportError: cannot import name patterns
Posted xqnq2007
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章
解决 ImportError: cannot import name pywrap_tensorflow
ImportError: cannot import name webdriver
ImportError: cannot import name patterns
window环境下ImportError: cannot import name 'Bar' from 'pyecharts'