mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 08:29:59 +03:00
Better name for a variable
This commit is contained in:
parent
6f36563b92
commit
c8af10349d
|
@ -439,18 +439,17 @@ class ModelSerializer(Serializer):
|
||||||
"""
|
"""
|
||||||
Creates a default instance of a nested relational field.
|
Creates a default instance of a nested relational field.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Field has reverse relation if it's referring to different model
|
# Field has reverse relation if it's referring to different model
|
||||||
if self.opts.model is not model_field.rel.to:
|
if self.opts.model is not model_field.rel.to:
|
||||||
# Get correct model from the relation
|
# Get correct model from the relation
|
||||||
obj_model = model_field.rel.to
|
model_class = model_field.rel.to
|
||||||
else:
|
else:
|
||||||
# Forward relation, no need for magic
|
# Forward relation, no need for magic
|
||||||
obj_model = model_field.model
|
model_class = model_field.model
|
||||||
|
|
||||||
class NestedModelSerializer(ModelSerializer):
|
class NestedModelSerializer(ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = obj_model
|
model = model_class
|
||||||
return NestedModelSerializer()
|
return NestedModelSerializer()
|
||||||
|
|
||||||
def get_related_field(self, model_field, to_many=False):
|
def get_related_field(self, model_field, to_many=False):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user