mirror of
https://github.com/django/daphne.git
synced 2025-07-13 09:22:17 +03:00
raise error if self.fields is empty
This commit is contained in:
parent
6eda634746
commit
4625266db6
|
@ -56,6 +56,8 @@ class WebsocketBinding(Binding):
|
||||||
"""
|
"""
|
||||||
if self.fields == ['__all__']:
|
if self.fields == ['__all__']:
|
||||||
self.fields = None
|
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)
|
data = serializers.serialize('json', [instance], fields=self.fields)
|
||||||
return json.loads(data)[0]['fields']
|
return json.loads(data)[0]['fields']
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user