raise error if self.fields is empty

This commit is contained in:
AlexejStukov 2016-07-22 08:17:49 +02:00 committed by GitHub
parent 6eda634746
commit 4625266db6

View File

@ -56,6 +56,8 @@ class WebsocketBinding(Binding):
"""
if self.fields == ['__all__']:
self.fields = None
elif not self.fields:
raise ValueError("You must set the fields attribute on Binding %r!" % self.__class__)
data = serializers.serialize('json', [instance], fields=self.fields)
return json.loads(data)[0]['fields']