Django的2.0版本之后使用新的规则,之前的url变成了path,如果要使用正则还需要引入re_path
from django.urls import path,re_path urlpatterns = [ path(‘admin/‘, admin.site.urls), path("userInfo",views.userInfo), re_path("index(?P<year>[0-9]{4})",views.index,{"user":"alex"},name="happy"), ]
原文:https://www.cnblogs.com/sq5288/p/8989453.html