I am working on Django project where I need to create a form for inputs. I tried to import
reverse
fromdjango.core.urlresolvers
. I got an error:line 2, in from django.core.urlresolvers import reverse ImportError: No module named 'django.core.urlresolvers'
I am using Python 3.5.2, Django 2.0 and MySQL.
score:475
Django 2.0 removes the django.core.urlresolvers
module, which was moved to django.urls
in version 1.10. You should change any import to use django.urls instead, like this:
from django.urls import reverse
Note that Django 2.0 removes some features that previously were in django.core.urlresolvers
, so you might have to make some more changes before your code works. See the features deprecated in 1.9 for details on those additional changes.
Similar question
- Django + mod_wsgi + apache: ImportError at / No module named djproj.urls
- ImportError at / No module named quickstart in django rest framework
- ImportError No module named localflavor.us.forms in Django 1.7
- Django - ImportError at /blog. No module named urls
- django : ImportError No module named myapp.views.hometest
- google app engine (python): ImportError no module named django
- ImportError at / No module named 'wsgi' in django
- Django with Heroku, No module named django core management
- Django ImportError no module named
- django ImportError at /admin/ no module named todo
score:0
In my case the problem was that I had outdated django-stronghold
installed (0.2.9). And even though in the code I had:
from django.urls import reverse
I still encountered the error. After I upgraded the version to django-stronghold==0.4.0
the problem disappeard.
score:1
If your builds on TravisCI are failing for this particular reason, you can resolve the issue by updating the Django Extensions in your requirements.txt
pip install --upgrade django-extensions
This will update the extensions to use Django 2+ modules.
Some more answer related to the same question
- django allauth ImportError at /admin/ No module named context_processors
- django admin load error: ImportError at /admin/login/ No module named backends
- Django ImportError No module named 'catalog.context_processors'
- Django - importError at /blog. (No module named urls)
- django Error : Caught ImportError while rendering: No module named comments
- Django - ImportError : no module named django.core.wsgi
- django import error - No module named core.management
- Django Rest Framework -- no module named rest_framework
- Django - "no module named django.core.management"
- Django import error - no module named django.conf.urls.defaults
score:1
To solve this either you down-grade the Django
to any version lesser than 2.0.
pip
install Django==1.11.29
.
score:1
Upgrading Django 1.9 (Python 2.7) to Django 3.2 (Python 3.9)
This could be solved in a one line bash replacement:
grep -ril "from django.core.urlresolvers" your_source_code_folder | xargs sed -i 's@from django.core.urlresolvers@from django.urls@g'
Related question
- "No module named simple" error in Django
- Running django tutorial tests fail - No module named polls.tests
- No module named 'polls.apps.PollsConfigdjango'; Django project tutorial 2
- No module named django but it is installed
- ImportError: No module named django.core.handlers.wsgi in install django mod_wsgi config on apache
- Import Error: No module named django
- Django Shell No module named settings
- Getting stuck at Django error: No module named registration
- Django Import Error: No module named apps
- Python Django : No module named security
score:2
urlresolver has been removed in the higher version of Django - Please upgrade your django installation. I fixed it using the following command.
pip install django==2.0 --upgrade
score:3
For those who might be trying to create a Travis Build, the default path from which Django is installed from the requirements.txt
file points to a repo whose django_extensions
module has not been updated. The only workaround, for now, is to install from the master branch using pip. That is where the patch is made. But for now, we'll have to wait.
You can try this in the meantime, it might help
- pip install git+https://github.com/chibisov/drf-extensions.git@master
- pip install git+https://github.com/django-extensions/django-extensions.git@master
score:3
For django version greater than 2.0 use:
from django.urls import reverse
in your models.py file.
score:5
use from django.urls import reverse instead of from django.core.urlresolvers import reverse
score:30
score:68
if you want to import reverse, import it from django.urls
from django.urls import reverse
Credit To: stackoverflow.com
More Query from same tag
- Help choosing between Django, Zope3 and Web2Py for WebService Server
- Load CSV file in Django view and turn into HTML table
- AttributeError at /upload_to_vimeo/ 'TypeError' object has no attribute 'message'
- How to call a specific python function from within a Django template
- django rest framework API edit function
- about the post_save signal and created argument
- How does dependencies isolation between MongoDB and Django work?
- How can I make it so different clients load unique rows each time (non-overlapping), without making user login sessions?
- Dynamically move an item from one list to another in Django
- How can I get an option selected by default in a forms.ChoiceField in Django?
- Django admin doesn't show translated enumerations in list view under Python 2.3
- Why does Django's flatpages allow logging a 404 error?
- Filtering starting from a Foreign key users that are not staff combined with other filters
- Why can't I take correct id of button jQuery in django loop in template
- multilingual formatting of date and time in django