Created
August 8, 2013 21:26
-
-
Save loic/6188915 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/django/db/models/base.py b/django/db/models/base.py | |
index 01ba559..6496aaa 100644 | |
--- a/django/db/models/base.py | |
+++ b/django/db/models/base.py | |
@@ -185,8 +185,10 @@ class ModelBase(type): | |
new_class._meta.concrete_model = new_class | |
# Do the appropriate setup for any model parents. | |
- o2o_map = dict([(f.rel.to, f) for f in new_class._meta.local_fields | |
- if isinstance(f, OneToOneField)]) | |
+ parent_link_map = {} | |
+ for field in new_class._meta.local_fields: | |
+ if isinstance(field, OneToOneField) and field.rel.parent_link: | |
+ parent_link_map[field.rel.to] = field | |
for base in parents: | |
original_base = base | |
@@ -208,8 +210,8 @@ class ModelBase(type): | |
if not base._meta.abstract: | |
# Concrete classes... | |
base = base._meta.concrete_model | |
- if base in o2o_map: | |
- field = o2o_map[base] | |
+ if base in parent_link_map: | |
+ field = parent_link_map[base] | |
elif not is_proxy: | |
attr_name = '%s_ptr' % base._meta.model_name | |
field = OneToOneField(base, name=attr_name, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment