Generic CRUD views: support for callable in post_ACTION_redirect
|Reported by:||Alberto Donato||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.