Django Form field initial value on failed validation
Posted
by John
on Stack Overflow
See other posts from Stack Overflow
or by John
Published on 2010-03-12T11:43:29Z
Indexed on
2010/03/12
11:47 UTC
Read the original article
Hit count: 203
django
|django-forms
Hi, how do I set the value of a field element after a form has been submitted but has failed validation? e.g.
if form.is_valid():
form.save()
else:
form.data['my_field'] = 'some different data'
I don't really want to put it in the view though and would rather have it as part of the form class.
Thanks
© Stack Overflow or respective owner