Opened 8 years ago

Closed 4 years ago

Last modified 4 years ago

#8001 closed New feature (fixed)

Make redirection URLs customizable in ModelAdmin views

Reported by: Julien Phalip Owned by: nobody
Component: contrib.admin Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As originated in [1], the ModelAdmin's save_add method has a post_url_continue argument to customize what page you should be
redirected to after saving a new object. This is very useful, but all other redirects are hard coded in all the views, including the save_add and save_change methods. Currently, those methods assume that there is only one standard way to route URLs in admin. This is a major drawback if you want to customize the URL scheme of your application's admin.

The proposed patch moves all hard-coded URLs to arguments of the corresponding methods. Those arguments are set to a default value, so the change is backward compatible. The benefit here, is that you can re-use the views and control where the user is redirected to after the view is processed.

[1] http://groups.google.com/group/django-developers/browse_thread/thread/e962ceb9478a167a

Attachments (4)

8001.admin_urls.diff (6.3 KB) - added by Julien Phalip 8 years ago.
8001_redirection_backward_compatibility.diff (2.0 KB) - added by Dario Ocles 5 years ago.
8001_redirection.diff (1.8 KB) - added by Dario Ocles 5 years ago.
8001_18072_18310.6.diff (9.9 KB) - added by Ramiro Morales 4 years ago.
Updated patch

Download all attachments as: .zip

Change History (15)

Changed 8 years ago by Julien Phalip

Attachment: 8001.admin_urls.diff added

comment:1 Changed 8 years ago by Eric Holscher

milestone: 1.0 maybe
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedDesign decision needed

comment:2 Changed 8 years ago by Jacob

milestone: 1.0 maybepost-1.0
Triage Stage: Design decision neededAccepted

This is a good idea and something needed by the admin, but as a "feature addition" it's a post-1.0 thing.

comment:3 Changed 8 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

comment:4 Changed 5 years ago by Luke Plant

Severity: Normal
Type: New feature

comment:5 Changed 5 years ago by Julien Phalip

Easy pickings: unset
Needs tests: set

See also #15294 for a related feature request.

Changed 5 years ago by Dario Ocles

Changed 5 years ago by Dario Ocles

Attachment: 8001_redirection.diff added

comment:6 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

Changed 4 years ago by Ramiro Morales

Attachment: 8001_18072_18310.6.diff added

Updated patch

comment:7 Changed 4 years ago by Ramiro Morales

I've attached a patch for this. Mostly to know if I'm interpreting Julien and Russell (in #18310) correctly and to start discussion about if this is an approach we want to pursue.

comment:8 Changed 4 years ago by Ramiro Morales

Work is ready for review in this branch https://github.com/ramiro/django/compare/master...8001_18310

comment:9 Changed 4 years ago by Ramiro Morales <cramm0@…>

Resolution: fixed
Status: newclosed

In 0b908b92a2ca4fb74a103e96bb75c53c05d0a428:

Fixed #8001 -- Made redirections after add/edit in admin customizable.

Also fixes #18310.

comment:10 Changed 4 years ago by Ramiro Morales <cramm0@…>

In 35d1cd0b28d1d9cd7bffbfbc6cc2e02b58404415:

Fixed #19505 -- A more flexible implementation for customizable admin redirect urls.

Work by Julien Phalip.

Refs #8001, #18310, #19505. See also 0b908b92a2ca4fb74a103e96bb75c53c05d0a428.

comment:11 Changed 4 years ago by Ramiro Morales <cramm0@…>

In 3ad34c231bb6e13c29dd268f9557a9cb241280fa:

[1.5.x] Fixed #19505 -- A more flexible implementation for customizable admin redirect urls.

Work by Julien Phalip.

Refs #8001, #18310, #19505. See also 0b908b92a2ca4fb74a103e96bb75c53c05d0a428.

35d1cd0b28d1d9cd7bffbfbc6cc2e02b58404415 from master.

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