[Answered ]-Django Forms โ€“ Can't raise validation error in tests

2๐Ÿ‘

โœ…

You need to remove the trailing commas from all the fields in your form.

Instead of

class NewUserForm(forms.Form):
    ...
    email = forms.EmailField(),
    ...

it should be

class NewUserForm(forms.Form):
    ...
    email = forms.EmailField()
    ...

At the moment, NewUserForm.email is a tuple, not a field, so any values for that field in the data dictionary are ignored. The only field without the trailing comma is super_balance, which is why it is the only error that appears when you pass a blank dictionary to the form.

๐Ÿ‘คAlasdair

Leave a comment