From 38b041bc0cf17acd46d2a821ee37af40b4e4d06f Mon Sep 17 00:00:00 2001 From: "Martin J. Laubach" Date: Tue, 10 Sep 2024 15:26:29 +0200 Subject: [PATCH] Fix tests failing --- form_designer/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/form_designer/models.py b/form_designer/models.py index 42408b7..79ace53 100644 --- a/form_designer/models.py +++ b/form_designer/models.py @@ -52,7 +52,7 @@ def validate_comma_separated_emails(value): validate_email(v.strip()) def email_field_choices(form: forms.ModelForm | None, required: bool=True) -> list[tuple[str, str]]: - if not form: + if not form or not form.instance or not form.instance.pk: return [] email_fields = form.instance.fields.filter(type='email') choices = [] if required else [('', '--')]