title: Django signals + channels: message not going through to client
body: <p>I want a signal to be sent every time a .save() is made</p>
  
  <pre><code>from django.db import models
  from django.forms.models import model_to_dict
  from django.db.models.signals import post_save
  from channels.layers import get_channel_layer
  from django.core.serializers.json import DjangoJSONEncoder
  from asgiref.sync import async_to_sync
  import json
  
  class DeribitFundingData(models.Model):
      time = models.DateTimeField()
      rate = models.FloatField()
  
      def __str__(self):
          return str(self.time)
  
  def save_post(sender, instance, **kwargs):
      channel_layer = get_channel_layer()
      data = model_to_dict(instance)
      json_data = json.dumps(data, cls=DjangoJSONEncoder)
      async_to_sync(channel_layer.group_send)(
          "echo_group",
          {"type": "stream", "data": json_data},
      )
  
  post_save.connect(save_post, sender=DeribitFundingData)
  </code></pre>
  
  <p>My consumer looks as follows, where <code>stream</code> is supposed to receive the data from <code>save_post</code>:</p>
  
  <pre><code>class StreamConsumer(AsyncConsumer):
  
      groups = ["echo_group"]
  
      async def websocket_connect(self, event):
          print("connected", event)
          await self.send({
              "type": "websocket.accept"
          })
  
      async def stream(self, event):
          data = event["message"]
  
          await self.send({
             'type': 'websocket.send',
             'text': data
          })
  </code></pre>
  
  <p>My .js:</p>
  
  <pre><code>&lt;script&gt;
      var loc = window.location
      var wsStart = "ws://"
      if (loc.protocol == 'https:'){
          wsStart = 'wss://'
      }
      var endpoint = wsStart + loc.host + "/websockets/"
      console.log(endpoint)
  
      socket = new WebSocket(endpoint);
  
      socket.onopen = function(message) {
          console.log("open", message);
        }
  
      socket.onmessage = function(message) {
          console.log("message", message);
      }
  
      socket.onerror = function(message) {
          console.log("error", message);
      }
  
      socket.onclose = function(message) {
          console.log("close", message);
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>In the shell I see that the websockets connection was established. Although the messages I'm sending from <code>post_save</code> are not going through. What's wrong?</p>