Code

Opened 6 years ago

Closed 3 years ago

#5970 closed Bug (fixed)

ChangeList.get_query_set() method ignores specified by model's admin manager QuerySet for search_fields lookup

Reported by: Nazar <911.17@…> Owned by: nobody
Component: contrib.admin Version: master
Severity: Normal Keywords: search_fields
Cc: gregoire@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

I use custom QuerySet for my model. It is returned by specified in admin options custom manager. When I used search box in change list to search some data I noticed that resulting QuerySet is not my custom QuerySet. As I could see later in admin contrib code - that's because searching method creates own QuerySet instead of using admin manager for this.

Attachments (2)

django_admin_search_bug.patch (770 bytes) - added by Nazar <911.17@…> 6 years ago.
admin_search_queryset.patch (720 bytes) - added by gregoire 5 years ago.

Download all attachments as: .zip

Change History (6)

Changed 6 years ago by Nazar <911.17@…>

comment:1 Changed 6 years ago by MichaelBishop

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

This patch is a one line modification which appears reasonable and very straight forward. The same "bug" appears in NFA (line 328, r7266) as well. The patch needs to be tested.

comment:2 Changed 5 years ago by gregoire

  • Cc gregoire@… added
  • Patch needs improvement set

I have the same problem in the current SVN.

I use the patch admin_search_queryset.patch, but it needs to clone the QuerySet using the private method _clone() because of the dup_select_related() call, which is not very clean.

Changed 5 years ago by gregoire

comment:3 Changed 3 years ago by gabrielhurley

  • Severity set to Normal
  • Type set to Bug

comment:4 Changed 3 years ago by Alex

  • Easy pickings unset
  • Resolution set to fixed
  • Status changed from new to closed
  • UI/UX unset

This was fixed at some point.

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.