Changes between Initial Version and Version 1 of Ticket #27897
- Timestamp:
- Mar 3, 2017, 4:45:31 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #27897
- Property Summary Cannot search for pk in the admin anymore → Cannot search for foreign key's pk in the admin anymore
-
Ticket #27897 – Description
initial v1 2 2 3 3 {{{ 4 class Bar(models.Model): 5 name = models.CharField( 6 max_length=256 7 ) 8 4 9 class Foo(models.Model): 5 10 name = models.CharField( 6 11 max_length=256 7 12 ) 13 bar = models.ForeignKey(Bar) 8 14 9 15 class FooAdmin(admin.ModelAdmin): 10 search_fields = [' pk']16 search_fields = ['bar__pk'] 11 17 }}} 12 18 … … 15 21 {{{ 16 22 File "/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 18 25 File "/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 20 28 File "/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 22 31 File "/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 24 34 File "/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)) 26 36 27 Exception Type: FieldDoesNotExist at /admin/a thome/disciplina/28 Exception Value: Foohas no field named u'pk'37 Exception Type: FieldDoesNotExist at /admin/app/foo/ 38 Exception Value: Bar has no field named u'pk' 29 39 }}} 30 40 31 41 Same code works fine in 1.8.16. 42 43 UPDATE: i've updated the test case as searching for the pk of the admin model does not work in 1.8.16 too