Code

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13081 closed (fixed)

Admin actions loose get-parameters in changelist view

Reported by: joh Owned by: SmileyChris
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

If the actions from the admin changelist view are used, the user will be redirected to the changeliste view, but if a filter or search was active, this information will be lost after redirection.

We discovert this behaviour as problematic in different satchmo/django-based shops we are hosting. If our users filter products for a specific category and use an action to mark some of them as featured products, they will end up in the changelist view, but see all products again. This also affects pagination in changelist views, because this information is also lost after redirection. Most of our users expected these filters to be remembered after action usage.

I stripped down the reason to the package django.contrib.admin.options in the class ModelAdmin. The method response_action will return a HttpResponseRedirect('.') when the action itself does not return a response. The Location-header will then be "fixed" in django.http.utils in the function fix_location_header. This function seems to enable some kind of "relative redirection feeling" in django. It uses HttpRequest.build_absolute_uri.

A simple fix / enhancement would be to change ModelAdmin.response_action to return HttpReponseRedirect(request.build_absolute_uri()) if the action itself does not return a response. Alternative would be to use HttpReponseRedirect(''), but I am not sure if this is a "clean" way.

I will attach patches for both variants shortly.

Attachments (3)

patch1.txt (538 bytes) - added by joh 4 years ago.
Suggestion 1 -- maybe not so "clean"
patch2.txt (564 bytes) - added by joh 4 years ago.
Suggestion 2
13081.diff (1.7 KB) - added by SmileyChris 4 years ago.

Download all attachments as: .zip

Change History (10)

Changed 4 years ago by joh

Suggestion 1 -- maybe not so "clean"

Changed 4 years ago by joh

Suggestion 2

comment:1 Changed 4 years ago by joh

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 4 years ago by russellm

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

Duplicate of #6903

comment:3 Changed 4 years ago by joh

  • Resolution duplicate deleted
  • Status changed from closed to reopened

I agree that this ticket is similar to #6903, but solving this problem for admin actions is currently not mentioned in #6903. In addition, I think that solving this problem for admin actions is very simple compared to a general solution for #6903.

The use case described in #6903 is different: It is only related to edit a single object. With admin actions there maybe no intermediate page (e.g. when setting some flags on marked instances) and loosing the filter parameters really is confusing to users.

I kindly request to rethink on this issue, but will not open this issue again if it is still considered a duplicate of #6903.

comment:4 Changed 4 years ago by russellm

  • Triage Stage changed from Unreviewed to Accepted

Apologies - you are correct. Admin actions are handled differently, so this is a separate problem (and should be much easier to solve).

Changed 4 years ago by SmileyChris

comment:5 Changed 4 years ago by SmileyChris

  • Owner changed from nobody to SmileyChris
  • Status changed from reopened to new
  • Triage Stage changed from Accepted to Ready for checkin

comment:6 Changed 4 years ago by lukeplant

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

(In [13696]) Fixed #13081 - Admin actions lose get-parameters in changelist view

Thanks to joh for report and to SmileyChris for patch.

comment:7 Changed 4 years ago by lukeplant

(In [13697]) [1.2.X] Fixed #13081 - Admin actions lose get-parameters in changelist view

Thanks to joh for report and to SmileyChris for patch.

Backport of [13696] from trunk

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.