Import "django.core.urlresolvers" could not be resolved
In earlier versions of Django (before version 2.0), the module
django.core.urlresolvers
was used for handling URL-related tasks.Starting from Django version 2.0, the functionality of
django.core.urlresolvers
was moved todjango.urls
. This change was made to simplify the URL handling system and to provide a more consistent and streamlined experience.If you encounter the error "ImportError: cannot import name 'urlresolvers' from 'django.core'", it indicates that you are using a version of Django that is 2.0 or later, and you should update your import statement to use
django.urls
instead.To resolve the issue, replace the import statement:
python from django.core.urlresolvers import ...
with the updated import statement:python from django.urls import ...
Update any references to
django.core.urlresolvers
in your code to use the equivalent functionality fromdjango.urls
. For example, if you were usingreverse
: ```python # Before from django.core.urlresolvers import reverse
# After from django.urls import reverse ```
- Make sure to review the Django documentation for the specific version you are using to ensure compatibility and to get the correct import statements.