diff options
| author | Simon Charette <charette.s@gmail.com> | 2016-03-28 14:14:24 -0400 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2016-03-28 21:15:16 -0400 |
| commit | 026574e03c6b6fd20a45f97b0470afb70e41fda4 (patch) | |
| tree | e2bc0ff9cdbe64e791679f8b9cc11953ba0fe537 /django | |
| parent | 97c5539a81c71f314314bc9796e7e87c41ae43b8 (diff) | |
[1.9.x] Fixed #26413 -- Fixed a regression with abstract model inheritance and explicit parent links.
Thanks Trac alias trkjgrdg for the report and Tim for investigation and review.
Backport of 67cf5efa31acb2916034afb15610b700695dfcb0 from master
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/base.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index e1a94d34d1..5635fabd6a 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -245,13 +245,21 @@ class ModelBase(type): field = None new_class._meta.parents[base] = field else: + base_parents = base._meta.parents.copy() + # .. and abstract ones. for field in parent_fields: new_field = copy.deepcopy(field) new_class.add_to_class(field.name, new_field) + # Replace parent links defined on this base by the new + # field as it will be appropriately resolved if required. + if field.one_to_one: + for parent, parent_link in base_parents.items(): + if field == parent_link: + base_parents[parent] = new_field # Pass any non-abstract parent classes onto child. - new_class._meta.parents.update(base._meta.parents) + new_class._meta.parents.update(base_parents) # Inherit managers from the abstract base classes. new_class.copy_managers(base._meta.abstract_managers) |
