Remove Field handling relations/relationship managers - use RelatedField/ManyRelatedField instead

This commit is contained in:
Tom Christie 2012-10-09 10:25:01 +01:00
parent 5c17a60176
commit dc52ceaaa2
2 changed files with 1 additions and 5 deletions

View File

@ -83,10 +83,6 @@ class Field(object):
if is_protected_type(value):
return value
all_callable = getattr(value, 'all', None)
if is_simple_callable(all_callable):
return [self.to_native(item) for item in value.all()]
elif hasattr(value, '__iter__') and not isinstance(value, (dict, basestring)):
return [self.to_native(item) for item in value]
return smart_unicode(value)

View File

@ -19,7 +19,7 @@ class TestGenericRelations(TestCase):
def test_reverse_generic_relation(self):
class BookmarkSerializer(serializers.ModelSerializer):
tags = serializers.Field(source='tags')
tags = serializers.ManyRelatedField(source='tags')
class Meta:
model = Bookmark