Tivix/django-rest-auth

ImportError: cannot import name 'url' from 'django.conf.urls'

UsamaHaide0786 opened this issue · 7 comments

(env_universal) usama@Usamas-MacBook-Pro DRF_test % python manage.py makemigrations
Traceback (most recent call last):
File "/Users/usama/Desktop/projects/DRF_test/manage.py", line 22, in
main()
File "/Users/usama/Desktop/projects/DRF_test/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/core/management/init.py", line 446, in execute_from_command_line
utility.execute()
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/core/management/init.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/core/management/base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/core/management/base.py", line 455, in execute
self.check()
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/core/management/base.py", line 487, in check
all_issues = checks.run_checks(
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/core/checks/registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/core/checks/urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/core/checks/urls.py", line 24, in check_resolver
return check_method()
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/urls/resolvers.py", line 480, in check
for pattern in self.url_patterns:
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/utils/functional.py", line 49, in get
res = instance.dict[self.name] = self.func(instance)
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/urls/resolvers.py", line 696, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/utils/functional.py", line 49, in get
res = instance.dict[self.name] = self.func(instance)
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/urls/resolvers.py", line 689, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/local/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/Users/usama/Desktop/projects/DRF_test/buzzshare/urls.py", line 8, in
path('rest-auth/', include('rest_auth.urls')),
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/urls/conf.py", line 38, in include
urlconf_module = import_module(urlconf_module)
File "/usr/local/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/rest_auth/urls.py", line 1, in
from django.conf.urls import url
ImportError: cannot import name 'url' from 'django.conf.urls' (/Users/usama/Desktop/projects/env_universal/lib/python3.9/site-packages/django/conf/urls/init.py)
(env_universal) usama@Usamas-MacBook-Pro DRF_test % pip install django-rest-auth

Is it not compatible with django 4

This problem has been solved here
try using
pip install django-rest-auth-forked

Hi!
This happen because url in django.conf.urls is deprecated in Django 4.0.x
To fix it import re_path as url from django.urls

This here will fix your issue:

Screen Shot 2023-03-12 at 23 07 32

BenBrostoff

even install pip but still this error occure

rom django.conf.urls import url, include
ImportError: cannot import name 'url' from 'django.conf.urls'

This here will fix your issue:

Screen Shot 2023-03-12 at 23 07 32

tried this way but still not working .

still not working, same if use path, or re_path
it appears only if using social-auth-app-django

Знімок екрана 2023-09-03 о 09 38 51