1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

model_split: Fixed #19236 - fixed error for abstract models with a split method

This commit is contained in:
Mike Johnson
2012-11-04 13:43:54 -08:00
parent 3e9b36688d
commit fcd3d4c68f
3 changed files with 34 additions and 9 deletions

View File

@@ -54,14 +54,16 @@ def add_lazy_relation(cls, field, relation, operation):
else:
# Look for an "app.Model" relation
try:
app_label, model_name = relation.split(".")
except ValueError:
# If we can't split, assume a model in current app
app_label = cls._meta.app_label
model_name = relation
except AttributeError:
# If it doesn't have a split it's actually a model class
if isinstance(relation, basestring):
try:
app_label, model_name = relation.split(".")
except ValueError:
# If we can't split, assume a model in current app
app_label = cls._meta.app_label
model_name = relation
else:
# it's actually a model class
app_label = relation._meta.app_label
model_name = relation._meta.object_name