mirror of
https://github.com/django/django.git
synced 2025-10-04 07:46:37 +00:00
Fixed #22994 -- regression with generic FK + admin list_view
The reason for the regression was that the GenericForeignKey field isn't something meta.get_field_by_name() should return. The reason is that a couple of places in Django expects get_field_by_name() to work this way. It could make sense to return GFKs from get_field_by_name(), but that should likely be done as part of meta refactoring or virtual fields refactoring patches. Thanks to glicerinu@gmail.com for the report and to Tim for working on the issue.
This commit is contained in:
parent
38e001ab6c
commit
9cd5201abd
4 changed files with 35 additions and 8 deletions
|
@ -441,7 +441,9 @@ class Options(object):
|
|||
for f, model in self.get_fields_with_model():
|
||||
cache[f.name] = cache[f.attname] = (f, model, True, False)
|
||||
for f in self.virtual_fields:
|
||||
cache[f.name] = (f, None if f.model == self.model else f.model, True, False)
|
||||
if hasattr(f, 'related'):
|
||||
cache[f.name] = cache[f.attname] = (
|
||||
f, None if f.model == self.model else f.model, True, False)
|
||||
if apps.ready:
|
||||
self._name_map = cache
|
||||
return cache
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue