diff --git a/subscription/forms.py b/subscription/forms.py index 1fcf37f4..7f8cd7d7 100644 --- a/subscription/forms.py +++ b/subscription/forms.py @@ -120,6 +120,12 @@ class SubscriptionNewUserForm(SubscriptionForm): email=self.cleaned_data.get("email"), date_of_birth=self.cleaned_data.get("date_of_birth"), ) + if self.errors: + # don't bother generating username, password and other data. + # The form validation failed anyway, so using a dummy User + # (just for Subscription.clean not to crash) is enough + self.instance.member = member + return super().clean() if self.cleaned_data.get("subscription_type") in [ "un-semestre", "deux-semestres", diff --git a/subscription/templates/subscription/fragments/creation_form_new_user.jinja b/subscription/templates/subscription/fragments/creation_form_new_user.jinja index ff36a9f1..e1c08e28 100644 --- a/subscription/templates/subscription/fragments/creation_form_new_user.jinja +++ b/subscription/templates/subscription/fragments/creation_form_new_user.jinja @@ -1,5 +1,5 @@