Make compatible with Django 4.1 (hopefully)
This commit is contained in:
parent
07a5e442b2
commit
1c0a31267d
|
@ -54,7 +54,13 @@ class MultiSelectField(models.CharField):
|
||||||
self.max_choices = kwargs.pop('max_choices', None)
|
self.max_choices = kwargs.pop('max_choices', None)
|
||||||
super(MultiSelectField, self).__init__(*args, **kwargs)
|
super(MultiSelectField, self).__init__(*args, **kwargs)
|
||||||
self.max_length = get_max_length(self.choices, self.max_length)
|
self.max_length = get_max_length(self.choices, self.max_length)
|
||||||
self.validators[0] = MaxValueMultiFieldValidator(self.max_length)
|
|
||||||
|
validator = MaxValueMultiFieldValidator(self.max_length)
|
||||||
|
if not self.validators:
|
||||||
|
self.validators.append(validator)
|
||||||
|
else:
|
||||||
|
self.validators[0] = validator
|
||||||
|
|
||||||
if self.min_choices is not None:
|
if self.min_choices is not None:
|
||||||
self.validators.append(MinChoicesValidator(self.min_choices))
|
self.validators.append(MinChoicesValidator(self.min_choices))
|
||||||
if self.max_choices is not None:
|
if self.max_choices is not None:
|
||||||
|
|
Loading…
Reference in a new issue