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)
Change History (2)
by , 14 years ago
Attachment: | django-callable-crud-redirect.diff added |
---|
comment:1 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Function-based generic views were deprecated by the introduction of class-based views in [14254]. Class-based views should solve this problem.