Opened 11 years ago

Closed 7 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


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@…> 11 years ago.
admin_search_queryset.patch (720 bytes) - added by gregoire 9 years ago.

Download all attachments as: .zip

Change History (6)

Changed 11 years ago by Nazar <911.17@…>

comment:1 Changed 10 years ago by MichaelBishop

Triage Stage: UnreviewedDesign 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 9 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 9 years ago by gregoire

Attachment: admin_search_queryset.patch added

comment:3 Changed 7 years ago by Gabriel Hurley

Severity: Normal
Type: Bug

comment:4 Changed 7 years ago by Alex Gaynor

Easy pickings: unset
Resolution: fixed
Status: newclosed
UI/UX: unset

This was fixed at some point.

Note: See TracTickets for help on using tickets.
Back to Top