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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user