ImportError at /
cannot import name 'url' from 'django.conf.urls' (/app/.heroku/python/lib/python3.9/site-packages/django/conf/urls/init.py)
Request Method: GET
Request URL: https://aas-system.herokuapp.com/
Django Version: 4.0.1
Exception Type: ImportError
Exception Value:
cannot import name 'url' from 'django.conf.urls' (/app/.heroku/python/lib/python3.9/site-packages/django/conf/urls/init.py)
Exception Location: /app/.heroku/python/lib/python3.9/site-packages/webpush/urls.py, line 1, in
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.9.10
Python Path:
['/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python39.zip',
'/app/.heroku/python/lib/python3.9',
'/app/.heroku/python/lib/python3.9/lib-dynload',
'/app/.heroku/python/lib/python3.9/site-packages']
Server time: Tue, 01 Feb 2022 07:52:34 0000
CodePudding user response:
If you are using Django 4.0 and higher then django.conf.urls.url()
is removed.
You can use re_path[Django-doc] in case of url
, which also use regex
as url
.
from django.urls import path, re_path
urlpatterns = [
re_path(r'^$', views.your_view_name),
]
CodePudding user response:
It looks like you are using Django 4. In this version, url from django.conf.url
no longer works.
https://docs.djangoproject.com/en/3.2/ref/urls/#url
So you have two options.
Use something below Django 3.2. I suspect that what you are doing on your local version. FYI, using pip freeze > requirements.txt
in your local environment is a good way to save your configuration and it can simplify the installation in other env.
Or update your code. You should then try re_path
in order to do so