fix ProhibitNullCharactersValidator for django111
@@ -5,7 +5,10 @@ from django.forms import widgets
from django.forms.fields import Field, CharField, ChoiceField, BooleanField, MultiValueField
from django.forms.utils import ErrorList
from django.core.exceptions import ValidationError
+try:
from django.core.validators import ProhibitNullCharactersValidator
+except:
+ ProhibitNullCharactersValidator=None
from django.utils.deconstruct import deconstructible
from django.utils.translation import ugettext_lazy as _, ugettext
from cmsplugin_cascade import app_settings
@@ -149,6 +152,7 @@ class ColorField(MultiValueField):
kwargs['initial'] = [default_color, inherit_color]
super().__init__(fields=fields, widget=widget, *args, **kwargs)
self.validators.append(ColorValidator(with_alpha))
+ if ProhibitNullCharactersValidator:
self.validators.append(ProhibitNullCharactersValidator())
def compress(self, data_list):
@@ -202,6 +206,7 @@ class SizeField(Field):
self.empty_value = ''
super().__init__(**kwargs)
self.validators.append(SizeUnitValidator(allowed_units))
+ if ProhibitNullCharactersValidator:
self.validators.append(ProhibitNullCharactersValidator())
def to_python(self, value):
