On Sat, Aug 13, 2011 at 4:41 AM, Jonas H. <jo...@lophus.org> wrote:

> On 08/13/2011 06:33 AM, Karen Tracey wrote:
>
>> On Thu, Aug 11, 2011 at 7:03 AM, Jonas H.<jo...@lophus.org>  wrote:
>>
>>  On 08/09/2011 12:45 AM, Jonas H. wrote:
>>>
>>>  Hello list!
>>>>
>>>> Is there any way to use a different value for a field when re-displaying
>>>> a form? I.e. if a user enters '42' into an IntegerField but made the
>>>> other fields not validate, how could that IntegerField be re-displayed
>>>> with '43'?
>>>>
>>>>
>>>>  Change the value in the form's data dictionary.
>>
>> Thanks Karen but that's not easily possible because that's an immutable
> QueryDict.


Because you've past request.POST directly to the form as the data dict. You
can instead pass a copy when instantiating the form, then you will be able
to modify the copy.


> Plus, afaik, fields can not access form instances so this code would have
> to live in the form subclass -- not practical in my use case.
>
>
Where I have done this (reluctantly) has been in the form (or perhaps it was
the field) clean method, where self is the form. I am not sure why in your
case you believe that to be not practical.

If you want to change the value displayed for a field in the form, you'll
either need to change the value in the data dictionary or change the guts of
how the form displays itself. The former is the easier choice, imo.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to