赞
踩
配置:Pthon 3.8.10-Django 4.1.1
使用命令创建数据库时:
python manage.py migrate
提示错误:
from django.conf.urls import re_path as url
ImportError: cannot import name 're_path' from 'django.conf.urls'
经查阅相关资料,并实际操作,解决问题,具体办法往下:
修改生成项目下的urls.py文件中的:from django.conf.urls import url
为:from django.urls import re_path as url
重新运行,正常执行。
注:
django.conf.urls.url()
was deprecated in Django 3.0, and is removed in Django 4.0+.
The easiest fix is to replace url()
with re_path(). re_path
uses regexes like url
, so you only have to update the import and replace url
with re_path
.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。