Opened 5 years ago

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

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@…> 5 years ago.

Download all attachments as: .zip

Change History (2)

Changed 5 years ago by Alberto Donato <alberto.donato@…>

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

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