Opened 16 years ago

Last modified 4 years ago

#6933 closed

You cannot search with spaces if search_fields is declared with "^" — at Initial Version

Reported by: Martín Conte Mac Donell <Reflejo@…> Owned by: nobody
Component: contrib.admin Version: newforms-admin
Severity: Normal Keywords: nfa-someday yandex-sprint ep2008
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

That is. When search_fields is declared to "starts with" you cannot perform queries with spaces.

File contrib/admin/views/main.py; Line 326:

for bit in self.query.split():
    or_queries = [models.Q(**{construct_search(field_name): bit}) for field_name in self.search_fields]
    other_qs = QuerySet(self.model)
    (...)
    qs = qs & other_qs

So, if for example i'm looking for "Hey dud" query will be:

qs.filter(fieldstartswith="Hey") & qs.filter(fieldstartswith("dud"))

Change History (0)

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