3

I am trying to create web services using the Django REST Framework. While running the server, when I try to access the admin page, I get the following error:

Invalid template library specified.
ImportError raised when trying to load 
'rest_framework.templatetags.rest_framework': No module named 'django.core.urlresolvers'

Note: I have added the rest_framework in the settings.

cezar
  • 11,616
  • 6
  • 48
  • 84

4 Answers4

6

Use this.

from django.urls import reverse

Django 1.10 the module django.core.urlresolvers deprecated. Please use above import which solve your issue.

Manoj Jadhav
  • 1,270
  • 1
  • 15
  • 23
3

Since Django 1.10 the module django.core.urlresolvers is deprecated. See the official documentation.

In order to resolve the issue you have to use compatible third-party packages. You didn't mention which version of Django REST Framework you're using, but I'd assume it's not DRF 3.x.x

Check the installed version of Django REST Framework and update it to the 3.7.x series (Stand: 2017-11-17).

cezar
  • 11,616
  • 6
  • 48
  • 84
  • Thanks for writing. I uninstalled the Django version 2.0 (which is considered as a testing version) and installed the official latest version 1.11.7, and now it is working. –  Nov 16 '17 at 19:06
  • Yes. Worked. Officiall document is not worth –  Feb 07 '18 at 09:01
3

I have the same issue like that and when I update Django rest framework and use the 3.7.7 version of that I could resolve the issue. you can use this command to solve this problem

pip install djangorestframework==3.7.7

Mad Javad
  • 494
  • 4
  • 5
1

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 instead of django.core.urlresolvers

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

Tangani
  • 29
  • 1
  • 5