Django错误导入ProhibitNullCharactersValidator

2021-12-01 12:11:52 发布

您现在位置:Python中文网/ 问答频道 /正文

当我运行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
)