title: Sending messages to groups in Django Channels 2
body: <p>I am completely stuck in that I cannot get group messaging to work with Channels 2! I have followed all tutorials and docs that I could find, but alas I haven't found what the issue seems to be yet. What I am trying to do right now is to have one specific URL that when visited should broadcast a simple message to a group named "events".</p>
  
  <p>First things first, here are the relevant and current settings that I employ in Django:</p>
  
  <pre><code>CHANNEL_LAYERS = {
      'default': {
          'BACKEND': 'channels_redis.core.RedisChannelLayer',
          'CONFIG': {
              'hosts': [('localhost', 6379)],
          },
      }
  }
  
  ASGI_APPLICATION = 'backend.routing.application'
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'rest_framework',
      'corsheaders',
      'channels',
      'channels_redis',
      'backend.api'
  ]
  </code></pre>
  
  <p>Next, here is my EventConsumer, extending the JsonWebsocketConsumer in a very basic way. All this does is echo back when receiving a message, which works! So, the simple send_json response arrives as it should, it is ONLY group broadcasting that does not work.</p>
  
  <pre><code>class EventConsumer(JsonWebsocketConsumer):
      groups = ["events"]
  
      def connect(self):
          self.accept()
  
      def disconnect(self, close_code):
          print("Closed websocket with code: ", close_code)
          self.close()
  
      def receive_json(self, content, **kwargs):
          print("Received event: {}\nFrom: {}\nGroups: 
                                 {}".format(content, 
                                            self.channel_layer, 
                                            self.groups))
  
          self.send_json(content)
  
      def event_notification(self, event):
          self.send_json(
              {
                  'type': 'test',
                  'content': event
              }
          )
  </code></pre>
  
  <p>And here is the URL configurations for the URL that I want to trigger the broadcast:</p>
  
  <p>Project urls.py</p>
  
  <pre><code>from backend.events import urls as event_urls
  
  urlpatterns = [
      url(r'^events/', include(event_urls))
  ]
  </code></pre>
  
  <p>Events app urls.py</p>
  
  <pre><code>from backend.events.views import alarm
  
  urlpatterns = [
      url(r'alarm', alarm)
  ]
  </code></pre>
  
  <p>And finally, the view itself where the group broadcast should take place:</p>
  
  <pre><code>from django.shortcuts import HttpResponse
  from channels.layers import get_channel_layer
  from asgiref.sync import async_to_sync
  
  
  def alarm(req):
      layer = get_channel_layer()
      async_to_sync(layer.group_send)('events', {'type': 'test'})
      return HttpResponse('&lt;p&gt;Done&lt;/p&gt;')
  </code></pre>