#2254 closed enhancement (invalid)
Add way to override POST content for generic create_update views
Reported by: | Owned by: | Jacob | |
---|---|---|---|
Component: | Generic views | Version: | dev |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The problem: the developer wants to use a generic view to allow the user to create/update some, but not all, columns in a row. Perhaps one column is a user ID which should always match the current user's ID. Perhaps one column should come from an ID in the URL.
The solution: Add a parameter to the create and update views that allow the developer to override parts of the POST.
The attached patch adds an override_dict parameter which, if provided, replaces the contents of the POST dictionary with the contents of override_dict for any key in the override_dict. This is done before validation occurs.
Attachments (1)
Change History (3)
by , 19 years ago
Attachment: | create_update.patch added |
---|
comment:1 by , 19 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
If you want to do this, call your own view function that overrides the relevant portions of the request and then passes on control to the generic view. We don't want to add infinite customisation to generic views when they can be achieved with three lines of code elsewhere.
comment:2 by , 19 years ago
The POST dictionary is immutable. Are you suggesting copying the POST dictionary, modifying that, then replacing request.POST with the modified copy?
Patch to add override_dict to create/update views