ImportError: No module named 'django.core.urlresolvers'

前端 未结 11 1449
孤街浪徒
孤街浪徒 2020-11-27 14:04

I am working on Django project where I need to create a form for inputs. I tried to import reverse from django.core.urlresolvers. I got an error:

11条回答
  •  余生分开走
    2020-11-27 14:08

    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.

提交回复
热议问题