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

Method clean

django/contrib/flatpages/forms.py:57–74  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

55 return url
56
57 def clean(self):
58 url = self.cleaned_data.get("url")
59 sites = self.cleaned_data.get("sites")
60
61 same_url = FlatPage.objects.filter(url=url)
62 if self.instance.pk:
63 same_url = same_url.exclude(pk=self.instance.pk)
64
65 if sites and same_url.filter(sites__in=sites).exists():
66 for site in sites:
67 if same_url.filter(sites=site).exists():
68 raise ValidationError(
69 _("Flatpage with url %(url)s already exists for site %(site)s"),
70 code="duplicate_url",
71 params={"url": url, "site": site},
72 )
73
74 return super().clean()

Callers

nothing calls this directly

Calls 5

ValidationErrorClass · 0.90
excludeMethod · 0.80
getMethod · 0.45
filterMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected