Closed
Description
At present, runserver_nostatic
works by simply shadowing the runserver
command from contrib.staticfiles
and replacing it with the runserver
command from Django core. However, this won't work with Channels, which needs its own runserver command.
A possible approach might be to require that runserver_nostatic
be at the top of the INSTALLED_APPS
list and for it to discover the next highest priority runserver
command (by inspecting the app registry and delegate to that, after setting the appropriate --no-static
flag.
This is obviously more complex and fragile, but it would be nice to have a simple (for the user) solution which was agnostic as to whether Channels was being used.
Activity
amureki commentedon Jun 13, 2016
@evansd
maybe not very related, but I wonder if whitenoise is working with current channels approach?
for example,
would not work, of course, but is there any way to make it work?
evansd commentedon Jun 13, 2016
@amureki
Yes, you can now integrate WhiteNoise by adding it to
settings.MIDDLEWARE_CLASSES
rather than editingwsgi.py
. This works with standard Django and with Channels.See:
http://whitenoise.evans.io/en/stable/changelog.html#simpler-cleaner-django-middleware-integration
edevil commentedon Jan 31, 2017
So can this be closed?
evansd commentedon Feb 1, 2017
@edevil No, I don't think so. WhiteNoise works fine with Channels, but the small "runserver_nostatic" feature doesn't. You can either ignore the issue in which case your app will use the default static file handling when in DEBUG mode, or you can manually pass the
--nostatic
option to runserver.sajoku commentedon Jun 19, 2017
I also ran into this and had
channels
defined after'whitenoise.runserver_nostatic',
. This will run the serverrunserver
fine but does not initiate the channels part. Very confusing (also because I'm new to Django and Python probably). So it seems there's nothing wrong with the configuration but the channels part will not be loaded at all. Even doingWhere
uadoua.routing.channel_routing
is non existent will not fail and just run the server.I'm running versions:
From above discussion I would think this will fail in the proposed solution right?
decentral1se commentedon Jun 26, 2017
FYI, I got bitten by this one pretty badly over at django/channels#684.
We probably should come up with a fix here. At the very least, a runtime warning.
edmorley commentedon Jun 26, 2017
I wonder if a better solution is to upstream a fix to Django that adds a way to disable the
contrib.staticfiles
via configuration pref or similar? WhiteNoise'srunserver_nostatic
would then no longer be required at all.runserver
commands django/channels#685evansd commentedon Jul 4, 2017
Fixed in ce74438, which will form part of the upcoming 4.0 release.
SHxKM commentedon Jul 9, 2018
@evansd Can I use 4.0 right now? My site is extremely slow with Channels 2 & WhiteNoise
timkofu commentedon Mar 30, 2022
Is this still an issue with
Django 4x
,Channels 3x
andWhitenoise 6x
?adamchainz commentedon Mar 30, 2022
There was a commit to fix this. Did you try? Please also don't comment on 5 year old issues, only open a new one if you have information.