Python – many to many fields in Django channels


@receiver (post_save, sender = HubNotify)
def create_task_verification_notification (sender, instance, created,
** Kwargs):
if instance:
channel_layer = get_channel_layer ()
async_to_sync (channel_layer.group_send) (
"gossip", {"type": "hub.notify",
"event": "Hub Notify",
"accept_hub_url": resol_url ("student: accept_hub")
pk =, notify =,
"reject_hub_url": resol_url ("student: reject_hub")
pk =, notify =,
"Notification": Instance.message



    async def hub_notify (self, event):
Expect self.send_json (event)
print ("Got message {} at {}". format (event, self.channel_name))

My where to create in the HubNotify object:

        excoms = User.objects.filter (hub_position = "E") |
User.objects.filter (hub_position = "L")
obj = HubNotify.objects
.create (sender = user, notification = request.user.username + & # 39; willing to
Join Hub & # 39;
messages.warning (request, & # 39; request sent & # 39;)
obj.receiver.add (* excoms) ()

I'm trying to create real-time notifications using Django channels. It uses signals to check if a notification is being generated and to send data to the frontend. This is basically a hub join request, where a user can send a request to the hub, which is sent to multiple users, and anyone can accept or reject it. The parameter pk in accept_hub_url is essentially HOW can I access request.user here?