解决新django中的path不能使用正则表达式的问题
新版的path虽然取代了之前的url,但是在写路由的时候不能在路由中直接写正则表达式,不然会找不到页面。
解决方法
使用re_path
fromdjango.urlsimportre_path,path urlpatterns=[ path('admin/',admin.site.urls), re_path('edit/(\d+)',views.edit), ]
这样就可以使用正则了。
以上这篇解决新django中的path不能使用正则表达式的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。