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.CharField

Custom 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 is True which enforces validation for all items.
clean(value)[source]

Custom clean which first validates the value first by using standard CharField and if all passes, it applies similar validations for each value once its split.

many_run_validators(values)[source]

Run each validation from many_validators for the cleaned values.

many_to_python(value)[source]

Method responsible to split the value into multiple values by using the delimiter and cleaning each one as per the child field.

many_validate(values)[source]

Hook for validating all values.