MCPcopy
hub / github.com/django/django / clean

Method clean

tests/forms_tests/tests/test_formsets.py:57–64  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

55
56class BaseFavoriteDrinksFormSet(BaseFormSet):
57 def clean(self):
58 seen_drinks = []
59
60 for drink in self.cleaned_data:
61 if drink["name"] in seen_drinks:
62 raise ValidationError("You may only specify a drink once.")
63
64 seen_drinks.append(drink["name"])
65
66
67# A FormSet that takes a list of favorite drinks and raises an error if

Callers 1

cleanMethod · 0.45

Calls 2

ValidationErrorClass · 0.90
appendMethod · 0.45

Tested by

no test coverage detected