diff options
| author | Tim Graham <timograham@gmail.com> | 2015-08-24 11:52:58 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-08-28 09:03:34 -0400 |
| commit | 3cc67a637a3cd1426d2ac87d7418600fa247ebb2 (patch) | |
| tree | f28b96aee6830482ee067f58f85b8212577a69b9 /django | |
| parent | 4f83bfa9e5ef10c6c9711ad529630d09a06ef413 (diff) | |
[1.8.x] Fixed #25299 -- Fixed crash with ModelAdmin.list_display value that clashes with a model reverse accessor.
Backport of 9607a0404188bbe612f05216f5a82df26f4b4e80 from master
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/utils.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py index 619e9ad796..8ddba506b0 100644 --- a/django/contrib/admin/utils.py +++ b/django/contrib/admin/utils.py @@ -293,9 +293,14 @@ def _get_non_gfk_field(opts, name): """ For historical reasons, the admin app relies on GenericForeignKeys as being "not found" by get_field(). This could likely be cleaned up. + + Reverse relations should also be excluded as these aren't attributes of the + model (rather something like `foo_set`). """ field = opts.get_field(name) - if field.is_relation and field.many_to_one and not field.related_model: + if (field.is_relation and + # Generic foreign keys OR reverse relations + ((field.many_to_one and not field.related_model) or field.one_to_many)): raise FieldDoesNotExist() return field |
