Django错误导入ProhibitNullCharactersValidator



当我运行我的django应用程序抛出这个错误,我这是一个与版本相关的错误,我使用python 3.6和django 1.11.10:

from rest_framework_swagger.views import get_swagger_view
File "/home/eddy/Documentos/apps/django/multas/venv/lib/python3.6/site-packages/rest_framework_swagger/views.py", line 3, in <module>
from rest_framework.renderers import CoreJSONRenderer
File "/home/eddy/Documentos/apps/django/multas/venv/lib/python3.6/site-packages/rest_framework/renderers.py", line 22, in <module>
from rest_framework import VERSION, exceptions, serializers, status
File "/home/eddy/Documentos/apps/django/multas/venv/lib/python3.6/site-packages/rest_framework/serializers.py", line 29, in <module>
from rest_framework.fields import get_error_detail, set_value
File "/home/eddy/Documentos/apps/django/multas/venv/lib/python3.6/site-packages/rest_framework/fields.py", line 15, in <module>
from django.core.validators import (
ImportError: cannot import name 'ProhibitNullCharactersValidator'
Unhandled exception in thread started by <_pydev_bundle.pydev_monkey._NewThreadStartupWithTrace object at 0x7f7046347f98>

这是我的requirements。txt

cx-Oracle==6.2
Django==1.11.10
pytz==2017.3
django-settings-export ==1.2.1
Pillow==5.1.0
zeep==2.5.0
pylokit==0.8.1
reportlab==3.5.5
templated-docs==0.3.1
django-debug-toolbar==1.9.1
djangorestframework-datatables==0.4.0
rarfile==3.0
django-rest-swagger==2.2.0
python-dateutil==2.7.3

抛出错误:

from django.core.validators import (
EmailValidator, MaxLengthValidator, MaxValueValidator, MinLengthValidator,
MinValueValidator, ProhibitNullCharactersValidator, RegexValidator,
URLValidator, ip_address_validators
)

ProhibitNullCharactersValidatorisDjango 2.0新增功能.

参见Django 2.0发布说明validators

Django REST框架3.12.0和更高版本不再支持Django 1.11了。参见djangorestframework 3.12.0

要求你必须升级您的Django降级Django REST框架到3.11.2

相关内容

  • 没有找到相关文章