How to access data when form.is_valid() is false


Question

When I have a valid Django form, I can access the data with form.cleaned_data. But how do I get at the data a user entered when the form is not valid i.e., form.is_valid is false.

I'm trying to access forms within a form set, so form.data seems to just give me a mess.

1
47
3/20/2013 8:13:31 PM

You can use

form.data['field_name']

This way you get the raw value assigned to the field.

42
6/16/2011 4:11:15 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon