I'm using a formset, and i'm trying to iterate through all the cleaned data.... except I keep getting a Keyerror no matter what field I try..
-- for form in formset:
data = form.cleaned_data
name = data["name"]
---> KeyError: "name"
class VariableForm(forms.Form):
name = forms.CharField()
default = forms.CharField(required=False)
Formset = formset_factory(
VariableForm,
can_delete=True,
extra=1,
)
What is wrong with my code?
I can even print(data) and it outputs:
{'DELETE': False, 'name': 'PATH', 'default': '/opt/tests'}
I can even do, for key, value in data.items(): and output
delete false
name PATH
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a90c04fa-6e1b-4a3d-a813-2661cc6df725%40googlegroups.com.
No comments:
Post a Comment