replace values in form.data when form fails validation

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-03-12T12:44:00Z Indexed on 2010/03/12 12:47 UTC
Read the original article Hit count: 262

Filed under:
|

Hi I have a form field which requires a json object as its value when it is rendered. When the form is submitted it returns a comma seperated string of ids as its value (not a json string). however if the form does not validate i want to turn this string of ids back into a json string so it will display properly (is uses jquery to render the json object correctly).

how would i do this?

I was thinking of overwriting the form.clean method but when I tried to change self.data['fieldname'] I got the error 'This QueryDict instance is immutable'

and when i tried to change self.cleaned_data['fieldname'] it didn't make a difference to the value of the field.

Thanks

© Stack Overflow or respective owner

Related posts about django

Related posts about django-forms