def extract_related_model(self, related_field, django_conf, loc=()):
"""
Extracts related model based on given field. It also checks that
given field is related to another model.
"""
model = self.extract_model(related_field, django_conf, loc)
related_field = model._meta.get_field(related_field)
if related_field.related_model is None:
raise utils.DRFAdapterException(
'Field {!r} is not related with another model'.format(
related_field), loc=loc)
return related_field.related_model
评论列表
文章目录