#26279: Admin search_fields doesn't support nested loopkup from JSOField
-------------------------------+--------------------
     Reporter:  ticosax        |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  contrib.admin  |    Version:  1.9
     Severity:  Normal         |   Keywords:  admin
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 Model
 {{{
 class Foo(models.Model):
     json = JSONField()
 }}}

 Admin
 {{{
 @admin.register(Foo)
 class FooAdmin(admin.ModelAdmin):
     search_fields = ('json__key',)
 }}}

 request from the browser (enter anything in search box).

 {{{GET /admin/project/foo/?q=123}}}

 I get this error

 {{{
 File "/home/.virtualenvs/project/lib/python3.4/site-
 packages/django/contrib/admin/views/main.py", line 356, in get_queryset
     request, qs, self.query)
   File "/home/.virtualenvs/project/lib/python3.4/site-
 packages/django/contrib/admin/options.py", line 903, in get_search_results
     if lookup_needs_distinct(self.opts, search_spec):
   File "/home/.virtualenvs/project/lib/python3.4/site-
 packages/django/contrib/admin/utils.py", line 32, in lookup_needs_distinct
     import pdb; pdb.set_trace()
   File "/home/.virtualenvs/project/lib/python3.4/site-
 packages/django/db/models/options.py", line 582, in get_field
     raise FieldDoesNotExist('%s has no field named %r' %
 (self.object_name, field_name))
 django.core.exceptions.FieldDoesNotExist: Foo has no field named 'key'
 }}}

 I'll be glad to have some guidance where is the best place to write the
 test.
 Then I can work on making a fix.

--
Ticket URL: <https://code.djangoproject.com/ticket/26279>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.2e43a0ed24eb1dff06b5a5d231a28682%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to