Skip to content

Commit

Permalink
PLD: use values list in tag serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
pld committed Aug 4, 2014
1 parent 914a290 commit 43751b4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion onadata/libs/serializers/tag_list_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ class TagListSerializer(serializers.WritableField):
def from_native(self, data):
if type(data) is not list:
raise ParseError("expected a list of data")

return data

def to_native(self, obj):
if obj is None:
return super(TagListSerializer, self).to_native(obj)

if type(obj) is not list:
return [tag.name for tag in obj.all()]
return list(obj.values_list('name', flat=True))

return obj

0 comments on commit 43751b4

Please sign in to comment.