From ddf88d53947cb3e248f52659ba8eba8cde27f47b Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Fri, 17 Nov 2023 13:03:48 +0200 Subject: [PATCH] make robust against None value --- core/forms.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/forms.py b/core/forms.py index 0d03d19..b27a8a8 100644 --- a/core/forms.py +++ b/core/forms.py @@ -218,8 +218,9 @@ class EntranceForm(ModelForm): ) def clean(self): - if self.cleaned_data.get("url").startswith("/"): - self._errors["url"] = self.error_class(["This field cannot start with a /."]) + if self.cleaned_data.get("url"): + if self.cleaned_data.get("url").startswith("/"): + self._errors["url"] = self.error_class(["This field cannot start with a /."]) return self.cleaned_data