Opened 8 years ago

Last modified 8 years ago

#27897 closed Bug

Cannot search for pk in the admin anymore — at Initial Version

Reported by: rm_ Owned by: nobody
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

On django 1.10.6 and python 2.7.9 given this Model and ModelAdmin:

class Foo(models.Model):
    name = models.CharField(
        max_length=256
    )

class FooAdmin(admin.ModelAdmin):
    search_fields = ['pk']

Each search returns:

File "/venv/local/lib/python2.7/site-packages/django/contrib/admin/views/main.py" in __init__
  81.         self.queryset = self.get_queryset(request)
File "/venv/local/lib/python2.7/site-packages/django/contrib/admin/views/main.py" in get_queryset
  359.             request, qs, self.query)
File "/venv/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in get_search_results
  994.                     if lookup_needs_distinct(self.opts, search_spec):
File "/venv/local/lib/python2.7/site-packages/django/contrib/admin/utils.py" in lookup_needs_distinct
  26.     field = opts.get_field(field_name)
File "/venv/local/lib/python2.7/site-packages/django/db/models/options.py" in get_field
  554.             raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, field_name))

Exception Type: FieldDoesNotExist at /admin/athome/disciplina/
Exception Value: Foo has no field named u'pk'

Same code works fine in 1.8.16.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top