I've been trying to get my head around the channels of Django and I can't get my message to be sent to my websocket.
Here is my consumers.py
import logging
from django.contrib.sites.models import Site
from django.utils import timezone
from channels import Group
from .models import *
import json
def send_free(message):
try:
pi = PInformation.objects.get(
pk=message.content.get('pk'),
)
except Parkplatzinformationen.DoesNotExist:
logging.error("PI not found!")
return
try:
message.reply_channel.send({
"text": 1,
})
except:
logging.exception('Problem sending %s' % (pi.name))
My routing.py
from channels.routing import route
from RESTAPI.consumers import send_free
channel_routing = [
route('send-free',send_free),
]
I'm getting the error AttributeError: 'NoneType' object has no attribute 'send'. It does however get the PInformation object so it does work a "bit". I'm calling it right after I'm saving the object.
Could you please give me some hints? The Getting Started guide uses it like I try to.