我遇到Django版本冲突的问题。
当我运行我的Django项目时,我得到了消息。
ImportError Traceback (most recent call last)
/usr/local/lib/python3.5/dist-packages/rest_framework/compat.py in <module>()
21 try:
---> 22 from django.urls import (
23 NoReverseMatch, RegexURLPattern, RegexURLResolver, ResolverMatch, Resolver404, get_script_prefix, reverse, reverse_lazy, resolve
ImportError: cannot import name 'RegexURLPattern'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-0639a9fdda0c> in <module>()
1 from urllib.parse import urlencode, quote_plus
2 from urllib.request import Request, urlopen
----> 3 from hospital.serializers import HospitalSerializer
~/earlierdoctorserver/hospital/serializers.py in <module>()
----> 1 from rest_framework.serializers import ModelSerializer
2 from .models import Hospital
3
4 class HospitalSerializer(ModelSerializer):
5 class Meta:
/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py in <module>()
28 from django.utils.translation import ugettext_lazy as _
29
---> 30 from rest_framework.compat import JSONField as ModelJSONField
31 from rest_framework.compat import postgres_fields, set_many, unicode_to_repr
32 from rest_framework.exceptions import ErrorDetail, ValidationError
/usr/local/lib/python3.5/dist-packages/rest_framework/compat.py in <module>()
24 )
25 except ImportError:
---> 26 from django.core.urlresolvers import ( # Will be removed in Django 2.0
27 NoReverseMatch, RegexURLPattern, RegexURLResolver, ResolverMatch, Resolver404, get_script_prefix, reverse, reverse_lazy, resolve
28 )
ImportError: No module named 'django.core.urlresolvers'
直视代码行,我的项目没有该语句,并且本地存储库中的包似乎存在问题。点数升级等都是最新的,我该如何解决?
感谢。
答案 0 :(得分:0)
升级到Django 2后,我收到类似的消息,试图运行python manage.py show_urls
。
升级django-extensions
为我解决了这个问题,但就您而言,您似乎需要升级Compat和Rest Framework库。