Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#2254 closed enhancement (invalid)

Add way to override POST content for generic create_update views

Reported by: djangotrac@… 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)

create_update.patch (1.6 KB ) - added by djangoblog@… 18 years ago.
Patch to add override_dict to create/update views

Download all attachments as: .zip

Change History (3)

by djangoblog@…, 18 years ago

Attachment: create_update.patch added

Patch to add override_dict to create/update views

comment:1 by Malcolm Tredinnick, 18 years ago

Resolution: invalid
Status: newclosed

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 djangotrac@…, 18 years ago

The POST dictionary is immutable. Are you suggesting copying the POST dictionary, modifying that, then replacing request.POST with the modified copy?

Note: See TracTickets for help on using tickets.
Back to Top