Opened 3 years ago

Closed 3 years ago

Last modified 2 years ago

#18310 closed New feature (fixed)

Make named return URLs configurable

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

Description

As of 1.4, The admin views have been modified to use named URLs instead of ../../.. paths for the redirects on success for add and change views (the return values of ModelAdmin.response_add() and ModelAdmin.response_change()).

However, the use of these named URLs requires that the named URL exists, which won't necessarily be the case.

As an example, django-treemenus adds some customisations to make it easy to define a tree hierarchy of MenuItem objects. To do this, it registers Menu with admin; A dummy ModelAdmin for MenuItem is used to provide the views for the entries on the menu.

MenuItem.response_add() tries to return to the named URL 'treemenus_menuitem_changelist' -- however this named URL doesn't exist, because MenuItem isn't registered with the admin.

There's no easy way to customize the named URL that you want the change view to return to. This would be an easy thing to configure with an argument (or arguments) to response_change and response_add.

Change History (5)

comment:1 Changed 3 years ago by ramiro

See also #8001.

comment:2 Changed 3 years ago by ramiro

I've attached a patch for this in attachment:8001_18072_18310.6.diff:ticket:8001. Mostly to know if I'm interpreting Russell's report correctly and to start discussion about if this is an approach we want to pursue.

comment:3 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:4 Changed 2 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:5 Changed 2 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