diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2014-07-14 14:23:34 +0300 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-07-14 10:50:41 -0400 |
| commit | 9cd5201abd24ba2632753029ee1957947cdc32f5 (patch) | |
| tree | 4a005b8e63b7092202829f5dbc1627987fcd8c59 /django | |
| parent | 38e001ab6caa8e5da68dbefd17322adcd2603c21 (diff) | |
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.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/options.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/options.py b/django/db/models/options.py index 39f0ab6f19..22fa8faf10 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -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 |
