Opened 7 years ago

Closed 3 years ago

Last modified 3 years ago

#8001 closed New feature (fixed)

Make redirection URLs customizable in ModelAdmin views

Reported by: julien 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 7 years ago.
8001_redirection_backward_compatibility.diff (2.0 KB) - added by burzak 4 years ago.
8001_redirection.diff (1.8 KB) - added by burzak 4 years ago.
8001_18072_18310.6.diff (9.9 KB) - added by ramiro 3 years ago.
Updated patch

Download all attachments as: .zip

Change History (15)

Changed 7 years ago by julien

comment:1 Changed 7 years ago by ericholscher

  • milestone set to 1.0 maybe
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 7 years ago by jacob

  • milestone changed from 1.0 maybe to post-1.0
  • Triage Stage changed from Design decision needed to Accepted

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 6 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:4 Changed 4 years ago by lukeplant

  • Severity set to Normal
  • Type set to New feature

comment:5 Changed 4 years ago by julien

  • Easy pickings unset
  • Needs tests set

See also #15294 for a related feature request.

Changed 4 years ago by burzak

comment:6 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

Changed 3 years ago by ramiro

Updated patch

comment:7 Changed 3 years ago by ramiro

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 3 years ago by ramiro

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

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

  • Resolution set to fixed
  • Status changed from new to closed

In 0b908b92a2ca4fb74a103e96bb75c53c05d0a428:

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

Also fixes #18310.

comment:10 Changed 3 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 3 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