mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 19:40:13 +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
|
||||
class ForeignKeySourceSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = ForeignKeySource
|
||||
fields = ('id', 'name', 'target')
|
||||
|
||||
|
||||
class ForeignKeyTargetSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = ForeignKeyTarget
|
||||
fields = ('id', 'name', 'sources')
|
||||
|
||||
|
||||
class ForeignKeySourceSerializer(serializers.ModelSerializer):
|
||||
class ForeignKeyTargetWithSourcesSerializer(serializers.ModelSerializer):
|
||||
sources = ForeignKeySourceSerializer(many=True)
|
||||
|
||||
class Meta:
|
||||
model = ForeignKeySource
|
||||
fields = ('id', 'name', 'target')
|
||||
model = ForeignKeyTarget
|
||||
fields = ('id', 'name', 'sources')
|
||||
|
||||
|
||||
# Nullable ForeignKey
|
||||
|
|
Loading…
Reference in New Issue
Block a user