Django随学笔记

2018-07-11  本文已影响0人  kazeno

1.问题:from django.conf.urls import *找不到patterns模块? Django-1.10,python27

答:这个特性在1.9就声明了deprecated. 1.10正式移除了。使用 django 1.10 需要改用 django.conf.urls.url() 示范代码:

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),

]

持续更新


上一篇下一篇

猜你喜欢

热点阅读