Opened 18 years ago
Last modified 5 years ago
#6933 closed
You cannot search with spaces if search_fields is declared with "^" — at Version 2
| Reported by: | 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 )
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 , 17 years ago
| Keywords: | nfa-someday added | 
|---|
comment:2 by , 17 years ago
| Description: | modified (diff) | 
|---|
  Note:
 See   TracTickets
 for help on using tickets.
    
Code is same here on trunk and nfa, this should not block merge.