新版本Django出现This was likely an oversight when migrating to django.urls.path()警告提示

 路由使用path(),

需要用到正则表达式使用re_path()

 

之前的写法是:

from django.contrib import admin
from django.urls import path, include
from article import urls

urlpatterns = [
    path('admin/', admin.site.urls),
    path('^*article/', include('article.urls'))
]

新版本的django中的urls.py如果需要用到正则,需要像如下这样写:

from django.contrib import admin
from django.urls import path, include, re_path
from article import urls

urlpatterns = [
    path('admin/', admin.site.urls),
    re_path('^.*article/', include('article.urls'))
]



posted @ 2019-05-07 13:54  C,python,linux  阅读(446)  评论(0编辑  收藏