#29816: Bug fix for ticket #29138
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:  nobody
  ConstantinoSchillebeeckx           |
                   Type:  Bug        |         Status:  new
              Component:             |        Version:  2.1
  contrib.admin                      |
               Severity:  Normal     |       Keywords:  autocomplete_fields
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I've put together a
 [https://github.com/ConstantinoSchillebeeckx/django/tree/fix-29138 bug
 fix] for the case when `autocomplete_fields` is used on a foreign-key
 field that has `on_fields` specified; bug originally reported
 [https://code.djangoproject.com/ticket/29138 here].

 '''Note''' I've been able to update the current unit tests to work with my
 new code; however one of the new unit tests doesn't pass. The error is a
 bit beyond my knowledge of how Django works and I would appreciate some
 help in fixing it:

 {{{
 ======================================================================
 ERROR: test_success
 (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File
 "/usr/local/opt/pyenv/versions/3.6.3/lib/python3.6/unittest/case.py", line
 59, in testPartExecutor
     yield
   File
 "/usr/local/opt/pyenv/versions/3.6.3/lib/python3.6/unittest/case.py", line
 605, in run
     testMethod()
   File
 
"/Users/constantino/Desktop/django/tests/admin_views/test_autocomplete_view.py",
 line 72, in test_success
     response =
 AutocompleteJsonView.as_view(**self.as_view_args_to_field)(request)
   File "/Users/constantino/Desktop/django/django/views/generic/base.py",
 line 68, in view
     return self.dispatch(request, *args, **kwargs)
   File "/Users/constantino/Desktop/django/django/views/generic/base.py",
 line 88, in dispatch
     return handler(request, *args, **kwargs)
   File
 "/Users/constantino/Desktop/django/django/contrib/admin/views/autocomplete.py",
 line 31, in get
     self.object_list = self.get_queryset()
   File
 "/Users/constantino/Desktop/django/django/contrib/admin/views/autocomplete.py",
 line 48, in get_queryset
     qs, search_use_distinct =
 self.model_admin.get_search_results(self.request, qs, self.term)
   File
 "/Users/constantino/Desktop/django/django/contrib/admin/options.py", line
 1026, in get_search_results
     queryset = queryset.filter(reduce(operator.or_, or_queries))
   File "/Users/constantino/Desktop/django/django/db/models/query.py", line
 844, in filter
     return self._filter_or_exclude(False, *args, **kwargs)
   File "/Users/constantino/Desktop/django/django/db/models/query.py", line
 862, in _filter_or_exclude
     clone.query.add_q(Q(*args, **kwargs))
   File "/Users/constantino/Desktop/django/django/db/models/sql/query.py",
 line 1263, in add_q
     clause, _ = self._add_q(q_object, self.used_aliases)
   File "/Users/constantino/Desktop/django/django/db/models/sql/query.py",
 line 1281, in _add_q
     current_negated, allow_joins, split_subq)
   File "/Users/constantino/Desktop/django/django/db/models/sql/query.py",
 line 1287, in _add_q
     split_subq=split_subq,
   File "/Users/constantino/Desktop/django/django/db/models/sql/query.py",
 line 1225, in build_filter
     condition = self.build_lookup(lookups, col, value)
   File "/Users/constantino/Desktop/django/django/db/models/sql/query.py",
 line 1087, in build_lookup
     raise FieldError('Related Field got invalid lookup:
 {}'.format(lookup_name))
 django.core.exceptions.FieldError: Related Field got invalid lookup:
 icontains
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29816>
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/067.5d1e7aec7c4cc03ccfea8aabe5e35a5b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to