【解决错误】Non-reversible reg-exp portion: '(?i'

在将Django升级到2.1后,运行 Django 自带后台后,或 使用 redirect 方法,就一直报错:Non-reversible reg-exp portion: '(?i'。django

 

错误一url

Django 2.X再也不支持的URL正则写法:spa

url(r'(?i)^a/$', view.fun1)

code

url(r'^(?i)a/$', view.fun1)

 

应该改成:blog

url(r'^a/$(?i)', view.fun1)

 

同时也建议 Django2.+中,建议不要再使用 url,而改成 path 或 re_path。io

--------------------------------------------------------------class

错误二后台

使用 django.shortcuts.redirect 报错:Non-reversible reg-exp portion: '(?i':
使用 django.http.HttpResponseRedirect 来代替 django.shortcuts.redirect
相关文章
相关标签/搜索