url_filter.fields module¶
-
class
url_filter.fields.MultipleValuesField(child=None, min_values=2, max_values=None, many_validators=None, delimiter=u', ', all_valid=True, *args, **kwargs)[source]¶ Bases:
django.forms.fields.CharFieldCustom Django field for validating/cleaning multiple values given in a single value separated by a delimiter.
Parameters: - child (Field, optional) – Another Django form field which should be used.
- min_values (int, optional) – Minimum number of values which must be provided. By default at least 2 values are required.
- max_values (int, optional) – Maximum number of values which can be provided. By default no maximum is enforced.
- max_validators (list, optional) – Additional validators which should be used to validate all values once split by the delimiter.
- delimiter (str, optional) – The delimiter by which the value will be split into
multiple values.
By default
,is used. - all_valid (bool, optional) – When
False, if any specific item does not pass validation it is ignored without failing complete field validation. Default isTruewhich enforces validation for all items.
-
clean(value)[source]¶ Custom
cleanwhich first validates the value first by using standardCharFieldand if all passes, it applies similar validations for each value once its split.
-
many_run_validators(values)[source]¶ Run each validation from
many_validatorsfor the cleaned values.