0π
β
I used the Django shell to call the forms manually. I found that I was executing the clean() method on all of the forms returned from the view. There were 2 filled out with data, and 2 blank. When my clean() method was iterating through them all, it returned a KeyError when it got to the first blank one.
I fixed my issue by using a try-statement and passing on KeyErrors.
π€exxy-
1π
Isnβt the clean method missing a return statement ? If I remember correctly it should always return the cleaned_data. Also the super call returns the cleaned_data so you should assign it there.
def clean(self):
cleaned_data = super(BaseTechOnsiteFormset, self).clean()
# use cleaned_data from here to validate your form
return cleaned_data
See: the django docs for more information
π€Jonas Geiregat
- [Answer]-How to change DateField format representation
- [Answer]-Displaying data from one model and using a form to update another associated by foreign key
- [Answer]-Using {%with to define a url in django
- [Answer]-Python django make a subclass use the parents table
Source:stackexchange.com