Opened 17 years ago

Last modified 4 years ago

#6933 closed

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

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 (last modified by Ramiro Morales)

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(field__startswith="Hey") & qs.filter(field__startswith("dud"))

Change History (2)

comment:1 by Karen Tracey <kmtracey@…>, 16 years ago

Keywords: nfa-someday added

Code is same here on trunk and nfa, this should not block merge.

comment:2 by Ramiro Morales, 16 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top