Opened 16 years ago

Closed 12 years ago

Last modified 12 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: dev
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 16 years ago.
8001_redirection_backward_compatibility.diff (2.0 KB ) - added by Dario Ocles 13 years ago.
8001_redirection.diff (1.8 KB ) - added by Dario Ocles 13 years ago.
8001_18072_18310.6.diff (9.9 KB ) - added by Ramiro Morales 12 years ago.
Updated patch

Download all attachments as: .zip

Change History (15)

by Julien Phalip, 16 years ago

Attachment: 8001.admin_urls.diff added

comment:1 by Eric Holscher, 16 years ago

milestone: 1.0 maybe
Triage Stage: UnreviewedDesign decision needed

comment:2 by Jacob, 16 years ago

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 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:4 by Luke Plant, 13 years ago

Severity: Normal
Type: New feature

comment:5 by Julien Phalip, 13 years ago

Easy pickings: unset
Needs tests: set

See also #15294 for a related feature request.

by Dario Ocles, 13 years ago

Attachment: 8001_redirection.diff added

comment:6 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

by Ramiro Morales, 12 years ago

Attachment: 8001_18072_18310.6.diff added

Updated patch

comment:7 by Ramiro Morales, 12 years ago

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 by Ramiro Morales, 12 years ago

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

comment:9 by Ramiro Morales <cramm0@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 0b908b92a2ca4fb74a103e96bb75c53c05d0a428:

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

Also fixes #18310.

comment:10 by Ramiro Morales <cramm0@…>, 12 years ago

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 by Ramiro Morales <cramm0@…>, 12 years ago

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