From 4625266db6047b78c91d1a97f63738955adb237b Mon Sep 17 00:00:00 2001 From: AlexejStukov Date: Fri, 22 Jul 2016 08:17:49 +0200 Subject: [PATCH] raise error if self.fields is empty --- channels/binding/websockets.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/channels/binding/websockets.py b/channels/binding/websockets.py index b211442..fcd97ef 100644 --- a/channels/binding/websockets.py +++ b/channels/binding/websockets.py @@ -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']