最佳答案
升级到 Django 4.0后,在运行 python manage.py runserver
时出现以下错误
...
File "/path/to/myproject/myproject/urls.py", line 16, in <module>
from django.conf.urls import url
ImportError: cannot import name 'url' from 'django.conf.urls' (/path/to/my/venv/lib/python3.9/site-packages/django/conf/urls/__init__.py)
我的 urls.py 如下:
from django.conf.urls
from myapp.views import home
urlpatterns = [
url(r'^$', home, name="home"),
url(r'^myapp/', include('myapp.urls'),
]