kpsul/kfet/consumers.py

22 lines
488 B
Python
Raw Normal View History

2016-09-01 00:45:44 +02:00
# -*- coding: utf-8 -*-
from django.core.serializers.json import json, DjangoJSONEncoder
2016-09-01 00:45:44 +02:00
from channels.generic.websockets import JsonWebsocketConsumer
class DjangoJsonWebsocketConsumer(JsonWebsocketConsumer):
"""Custom Json Websocket Consumer.
Encode to JSON with DjangoJSONEncoder.
"""
@classmethod
def encode_json(cls, content):
return json.dumps(content, cls=DjangoJSONEncoder)
class KPsul(DjangoJsonWebsocketConsumer):
groups = ['kfet.kpsul']