I am working on django restframework project. I build it and it was working well but then I tried makemigrations and I got following error. Please help me.
File "/code/eventful/manage.py", line 22, in <module>
main()
File "/code/eventful/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 373, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 412, in execute
self.check()
File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 438, in check
all_issues = checks.run_checks(
File "/usr/local/lib/python3.10/site-packages/django/core/checks/registry.py", line 77, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/usr/local/lib/python3.10/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python3.10/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 446, in check
for pattern in self.url_patterns:
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 632, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 625, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/code/eventful/eventful/urls.py", line 25, in <module>
path('api/rest-auth/', include('rest_auth.urls')),
File "/usr/local/lib/python3.10/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/usr/local/lib/python3.10/site-packages/rest_auth/urls.py", line 1, in <module>
from django.conf.urls import url
ImportError: cannot import name 'url' from 'django.conf.urls' (/usr/local/lib/python3.10/site-packages/django/conf/urls/__init__.py)
I tried makemigrations for my django project but I have got that error and I do not have any idea about this error. Can anybody help me. Please!
CodePudding user response:
the url
was removed in Django 4.0
Look at the release notes here:
https://docs.djangoproject.com/pl/4.0/releases/4.0/#features-removed-in-4-0
django.conf.urls.url() is removed
CodePudding user response:
As of django-4.0, the url
function is removed. Indeed, in the release notes we see:
django.conf.urls.url()
is removed.
You thus are using rest_auth
which is incompatible with the Django version. The django-rest-auth
project [GitHub] still uses the url(…)
function in the urls.py
[GitHub].
You thus should downgrade Django (to django-3.2) to work with the django-rest-auth
, or you should wait until the django-rest-auth
makes a release that is compatible with django-4.0.