简体   繁体   中英

django locale-url import error cannot import name 'urlresolvers' from 'django.core'

I am working through docs

This is the import statement:

from django.core import urlresolvers

And I am getting this error:

ImportError: cannot import name 'urlresolvers' from 'django.core'
(xxx/nbrl-project/nbrlenv/lib/python3.8/site-packages/django/core/__init__.py)

can anyone help me with this?

Acording to the provided docs:

localeurl application requires Django 1.3 or higher and Python 2.6 or 2.7.

You are probably using a higher version of django. Since version 2.0, the django.core.urlresolvers module has been moved to django.urls

from django.urls import reverse

If possible, keep your django at the latest version, since version 1.3 is no longer supported.

If you are creating a new project, you should go for Django's own URL internationalization: https://docs.djangoproject.com/en/3.1/topics/i18n/translation/#url-internationalization

Try not to use un-maintained versions of Django and any other library, if you can help it. This will spare you a load of trouble.

Citing from the docs that you have linked ( https://django-localeurl.readthedocs.io/en/latest/index.html ):

Warning

django-localeurl is currently un-maintained (so pull requests will not be reviewed or merged), and its approach has been obsoleted by the introduction of locale-aware URL patterns in Django itself. If you are nonetheless interested in taking over maintenance of django-localeurl, please file an issue to volunteer. Thank you!

Try delete "allauth.account.auth_backends.AuthenticationBackend", from setting.py if you using django-allauth and configure it correctly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM