Changes between Initial Version and Version 1 of Ticket #27897


Ignore:
Timestamp:
Mar 3, 2017, 4:45:31 AM (8 years ago)
Author:
rm_
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #27897

    • Property Summary Cannot search for pk in the admin anymoreCannot search for foreign key's pk in the admin anymore
  • Ticket #27897 – Description

    initial v1  
    22
    33{{{
     4class Bar(models.Model):
     5    name = models.CharField(
     6        max_length=256
     7    )
     8
    49class Foo(models.Model):
    510    name = models.CharField(
    611        max_length=256
    712    )
     13    bar = models.ForeignKey(Bar)
    814
    915class FooAdmin(admin.ModelAdmin):
    10     search_fields = ['pk']
     16    search_fields = ['bar__pk']
    1117}}}
    1218
     
    1521{{{
    1622File "/venv/local/lib/python2.7/site-packages/django/contrib/admin/views/main.py" in __init__
    17   81.         self.queryset = self.get_queryset(request)
     23  78.         self.queryset = self.get_queryset(request)
     24
    1825File "/venv/local/lib/python2.7/site-packages/django/contrib/admin/views/main.py" in get_queryset
    19   359.             request, qs, self.query)
     26  346.         qs, search_use_distinct = self.model_admin.get_search_results(request, qs, self.query)
     27
    2028File "/venv/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in get_search_results
    21   994.                     if lookup_needs_distinct(self.opts, search_spec):
     29  908.                     if lookup_needs_distinct(self.opts, search_spec):
     30
    2231File "/venv/local/lib/python2.7/site-packages/django/contrib/admin/utils.py" in lookup_needs_distinct
    23   26.     field = opts.get_field(field_name)
     32  32.         field = opts.get_field(field_name)
     33
    2434File "/venv/local/lib/python2.7/site-packages/django/db/models/options.py" in get_field
    25   554.             raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, field_name))
     35  619.             raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, field_name))
    2636
    27 Exception Type: FieldDoesNotExist at /admin/athome/disciplina/
    28 Exception Value: Foo has no field named u'pk'
     37Exception Type: FieldDoesNotExist at /admin/app/foo/
     38Exception Value: Bar has no field named u'pk'
    2939}}}
    3040
    3141Same code works fine in 1.8.16.
     42
     43UPDATE: i've updated the test case as searching for the pk of the admin model does not work in 1.8.16 too
Back to Top