django2.0url的变动

WARNINGS:
?: (urls.W001) Your URL pattern '^$' uses include with a route ending with a '$'. Remove the dollar from the route to avoid problems including URLs.

从Django2.0开始:

1.把url函数换成path

2.不在使用^、$作为路由

from django.contrib import admin
from django.urls import path            #此处应用path,老板本使用的是url
from appchat import views

urlpatterns = [
path('admin/', admin.site.urls),
path('login/', views.acc_login,name='login'),
path('logout/', views.acc_logout, name='logout'),
path('',views.index,name='index'),                               #此处设置为首页,以前写法是'^$',新版本不再使用^、$,只需要‘’就可以

]

猜你喜欢

转载自www.cnblogs.com/qiangayz/p/9130642.html