Clean up implementation of admin post-save redirects
|Reported by:||julien||Owned by:||julien|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||no|
The implementation in 0b908b92a2ca4fb74a103e96bb75c53c05d0a428 to fix #8001 and #18310 introduces some new parameters to ModelAdmin's response_add and response_change methods to control where the user should be redirected after saving an object. One issue with that approach is that it exposes those methods' internal redirection behaviors in their signatures. I think it would be much more flexible to encapsulate those behaviors in a separate method, which could then easily be overridden to provide completely new, custom behaviors. I also think this would make the implementation to fix #6903 easier, although I still need to confirm that (I'm currently working on that ticket, so I should find out soon).
I'm attaching a patch with the suggested new approach. This still needs tests. To apply it, you will first need to revert the original commit, i.e.: git revert 0b908b92a2ca4fb74a103e96bb75c53c05d0a428
I'm marking this ticket as blocker to avoid shipping a new API that I feel a bit uncomfortable with. I'll discuss with Ramiro ASAP to check that this new approach is satisfactory.
Also, note that due to the commit reversion, we're left to deal with the hardcoded url path post_url_continue in the response_add method. I've addressed that in a slightly backwards-incompatible way. Even though we're late in the beta phase, I think we should still move ahead with this BC change since the admin isn't part of the stable API and I'd like to keep the admin's API as clean as possible moving forward. For more details on that, see comments 6 to 12 in #15294.
Change History (7)
Changed 15 months ago by julien
comment:1 Changed 15 months ago by Ramiro Morales <cramm0@…>
- Resolution set to fixed
- Status changed from new to closed