Form should use a copy of data passed to it
|Reported by:||Owned by:||Adrian Holovaty|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Usually, one passes POST data directly to the form like so:
if request.method == 'POST': form = MyForm(request.POST)
and request.POST is an immutable QueryDict. This means that you cannot fiddle with the data, for say if you wanted to remove keys so that the data doesn't get redisplayed when the form has errors.
I could make the copy in my own code:
form = MyForm(request.POST.copy())
but just thought this might be something useful to do more generally.
If anyone has a better alternative for not redisplaying submitted data, please mention it.
Change History (4)
comment:1 Changed 9 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Design decision needed|