Form should use a copy of data passed to it
|Reported by:||Gary Wilson <gary.wilson@…>||Owned by:||adrian|
|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)
Changed 7 years ago by Gary Wilson <gary.wilson@…>
comment:1 Changed 7 years ago by Gary Wilson <gary.wilson@…>
- Has patch set
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Design decision needed
comment:2 Changed 7 years ago by mtredinnick
- Resolution set to wontfix
- Status changed from new to closed