mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 12:00:12 +03:00
Add ForeignKeyTargetWithSourcesSerializer
to relations/pk tests
This serializer nests the reverse `sources` relation, to test that the reverse relation is iterated over correctly.
This commit is contained in:
parent
bd7925c181
commit
c36e2eabe9
|
@ -26,16 +26,24 @@ class ManyToManySourceSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
|
|
||||||
# ForeignKey
|
# ForeignKey
|
||||||
|
class ForeignKeySourceSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = ForeignKeySource
|
||||||
|
fields = ('id', 'name', 'target')
|
||||||
|
|
||||||
|
|
||||||
class ForeignKeyTargetSerializer(serializers.ModelSerializer):
|
class ForeignKeyTargetSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ForeignKeyTarget
|
model = ForeignKeyTarget
|
||||||
fields = ('id', 'name', 'sources')
|
fields = ('id', 'name', 'sources')
|
||||||
|
|
||||||
|
|
||||||
class ForeignKeySourceSerializer(serializers.ModelSerializer):
|
class ForeignKeyTargetWithSourcesSerializer(serializers.ModelSerializer):
|
||||||
|
sources = ForeignKeySourceSerializer(many=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ForeignKeySource
|
model = ForeignKeyTarget
|
||||||
fields = ('id', 'name', 'target')
|
fields = ('id', 'name', 'sources')
|
||||||
|
|
||||||
|
|
||||||
# Nullable ForeignKey
|
# Nullable ForeignKey
|
||||||
|
|
Loading…
Reference in New Issue
Block a user