aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/relations_hyperlink.py
diff options
context:
space:
mode:
authorTom Christie2013-04-23 11:31:38 +0100
committerTom Christie2013-04-23 11:31:38 +0100
commit4bf1a09baeb885863e6028b97c2d51b26fb18534 (patch)
tree1ccdcf4b09f248c19b257a731ea4e25b5d2e10eb /rest_framework/tests/relations_hyperlink.py
parentbcf4cb2b4e2fdf10b0df01ece1aa8ce9dc97285a (diff)
downloaddjango-rest-framework-4bf1a09baeb885863e6028b97c2d51b26fb18534.tar.bz2
Ensure implementation of reverse relations in 'fields' is backwards compatible
Diffstat (limited to 'rest_framework/tests/relations_hyperlink.py')
-rw-r--r--rest_framework/tests/relations_hyperlink.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/rest_framework/tests/relations_hyperlink.py b/rest_framework/tests/relations_hyperlink.py
index b5702a48..b1eed9a7 100644
--- a/rest_framework/tests/relations_hyperlink.py
+++ b/rest_framework/tests/relations_hyperlink.py
@@ -26,42 +26,44 @@ urlpatterns = patterns('',
)
+# ManyToMany
class ManyToManyTargetSerializer(serializers.HyperlinkedModelSerializer):
- sources = serializers.HyperlinkedRelatedField(many=True, view_name='manytomanysource-detail')
-
class Meta:
model = ManyToManyTarget
+ fields = ('url', 'name', 'sources')
class ManyToManySourceSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = ManyToManySource
+ fields = ('url', 'name', 'targets')
+# ForeignKey
class ForeignKeyTargetSerializer(serializers.HyperlinkedModelSerializer):
- sources = serializers.HyperlinkedRelatedField(many=True, view_name='foreignkeysource-detail')
-
class Meta:
model = ForeignKeyTarget
+ fields = ('url', 'name', 'sources')
class ForeignKeySourceSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = ForeignKeySource
+ fields = ('url', 'name', 'target')
# Nullable ForeignKey
class NullableForeignKeySourceSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = NullableForeignKeySource
+ fields = ('url', 'name', 'target')
-# OneToOne
+# Nullable OneToOne
class NullableOneToOneTargetSerializer(serializers.HyperlinkedModelSerializer):
- nullable_source = serializers.HyperlinkedRelatedField(view_name='nullableonetoonesource-detail')
-
class Meta:
model = OneToOneTarget
+ fields = ('url', 'name', 'nullable_source')
# TODO: Add test that .data cannot be accessed prior to .is_valid