0

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?

Risadinha
  • 16,058
  • 2
  • 88
  • 91
avi giri
  • 1
  • 2
  • check [this](https://stackoverflow.com/questions/43139081/importerror-no-module-named-django-core-urlresolvers) thread. I think it will solve your issue. – mustafasencer Aug 10 '20 at 13:17
  • Does this answer your question? [ImportError: No module named 'django.core.urlresolvers'](https://stackoverflow.com/questions/43139081/importerror-no-module-named-django-core-urlresolvers) – Risadinha Aug 10 '20 at 13:33
  • no sir its not helping. i have already tried this. error is coming from localeurl/models/py where reverse is not imported – avi giri Aug 10 '20 at 13:34

3 Answers3

1

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.

Diego Magalhães
  • 1,704
  • 9
  • 14
  • Note that Django 1.3 is from 2011, not maintained anymore - "beyond old". If you have the choice, especially if you start a new project - do not use it anymore. Last commit of https://bitbucket.org/carljm/django-localeurl/commits/ is from 2015, it is not maintained anymore. Django offers already built-in ways to reflect the language in the url. – Risadinha Aug 10 '20 at 13:36
  • does this mean localeurl is not good to use? can you suggest me some other library of such – avi giri Aug 10 '20 at 13:40
  • Yes @Risadinha. Use an older django version isn't recommended due to lack of support and of course, security. – Diego Magalhães Aug 10 '20 at 13:42
  • @avigiri Django can handle this, check here https://docs.djangoproject.com/en/3.1/topics/i18n/translation/#url-internationalization – Diego Magalhães Aug 10 '20 at 13:47
0

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!

Risadinha
  • 16,058
  • 2
  • 88
  • 91
0

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

Mohamed Slimane
  • 311
  • 3
  • 14