Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Access URL Params in Django Channels Consumers

If i had the following url in routing.py:

/rooms/<int:id>/

How would I access the id parameter from withing a JSONWebsocketConsumer?

like image 982
svoruganti Avatar asked Oct 24 '25 15:10

svoruganti


1 Answers

I think the documentation needs updating, 'url_path' didn't work for me, but 'url_route' did.

self.scope['url_route']['kwargs']['id']
like image 87
devdrc Avatar answered Oct 26 '25 04:10

devdrc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!