#32649: django.contrib.admin.ModelAdmin.search_fields crashes for a search term
with three quotes
-------------------------------+--------------------------------------
     Reporter:  Dlis           |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  contrib.admin  |                  Version:  3.2
     Severity:  Normal         |               Resolution:
     Keywords:  admin, search  |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by Dlis):

 If somebody has such the problem, here is our temporary fix which was
 added to our internal basic ModelAdmin:

 {{{
 def get_search_results(self, request, queryset, search_term):
     parts = search_term.split()
     try:
         for part in text.smart_split(search_term):
             text.unescape_string_literal(part)
     except ValueError:
         parts = map(lambda t: str(t).strip('"').strip("'"), parts)
     return super().get_search_results(request, queryset, ' '.join(parts))
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32649#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/062.412784acc345fe1e75649f6429aaf479%40djangoproject.com.

Reply via email to