Opened 9 years ago

Closed 9 years ago

Last modified 9 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: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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@… 9 years ago.
Patch to add override_dict to create/update views

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by djangoblog@…

Patch to add override_dict to create/update views

comment:1 Changed 9 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to 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 Changed 9 years ago by djangotrac@…

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