That's correct - Django middleware only runs on HTTP request objects, and so doesn't work in a WebSocket context. The recommended alternative is to write ASGI middleware for this purpose.
Unfortunately, there is not good documentation on this yet, but you can see a bit about it here, in the authentication docs: http://channels.readthedocs.io/en/latest/topics/authentication.html#custom-authentication Andrew On Fri, May 4, 2018 at 6:12 AM Marius Räsener <m...@mehr-handwerk.de> wrote: > Hey everybody, > > We are using a Middleware to inject postgresql schemas into queries based > on a subdomain. You can have a look how it‘s done here: > > https://github.com/systori/systori/blob/dev/systori/apps/company/middleware.py > > Now, for channels I‘ve noticed that there is no usual request, right? > So, if I‘m connecting a WS it doesn‘t hit the Middleware. > Are there any guides or docs available or any recommendations how to solve > this properly for channels? > > Thx, > Marius > > -- > 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+unsubscr...@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/6534824B-4E3B-4E39-8DA0-DF807A84CADC%40mehr-handwerk.de > <https://groups.google.com/d/msgid/django-users/6534824B-4E3B-4E39-8DA0-DF807A84CADC%40mehr-handwerk.de?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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+unsubscr...@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/CAFwN1upH03QzfeycVhHwJ2Bqks96y26npDNZa%2B5etkUWPn0mPw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.