Opened 14 years ago

Closed 14 years ago

#13953 closed (fixed)

Generic CRUD views: support for callable in post_ACTION_redirect

Reported by: Alberto Donato Owned by: nobody
Component: Generic views Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

the current post_save/delete_redirect mechanism doesn't allow to use dynamically-reversed URLs nor named ones, since it only accepts a string with patterns.

The attached patch allows to use a callable as post_save/delete_redirect parameter, which is called with current object as parameter.
This allows to do both simple name-based redirect and object-based ones.

For delete view, the redirect is calculated before deleting the object, also providing access to current object.

It would also be possible to pass the Request object to the callable, to provide greater flexibility, but IMHO doing something more than a reverse() in the redirect would be beyond the scope of the generic view usage.

Attachments (1)

django-callable-crud-redirect.diff (8.3 KB ) - added by Alberto Donato <alberto.donato@…> 14 years ago.

Download all attachments as: .zip

Change History (2)

by Alberto Donato <alberto.donato@…>, 14 years ago

comment:1 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

Function-based generic views were deprecated by the introduction of class-based views in [14254]. Class-based views should solve this problem.

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