Wednesday, February 22, 2017

Re: django channels in the shell

solved it.. I had to explicitly add the hosts parameter

from django.conf import settings
from django.utils.module_loading import import_string

config = getattr(settings, "CHANNEL_LAYERS", {})
hosts = config['default']['CONFIG']['hosts']
backend_class = import_string(config['default']['BACKEND'])
channel_layer = backend_class(hosts=hosts)

channel = channel_layer.group_channels('poll')[0]
channel_layer.send(channel, {"text": "hello world!"})

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b4e8cb61-4428-48d6-aeb9-463e21398dfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment