-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WHITENOISE_AUTOREFRESH = False does not prefix static urls correctly #258
Comments
Hi, thanks for this exemplary bug report! I'll add the 3.1 beta to the test matrix and get this fixed. |
@ajslater I'm struggling to reproduce this. Can you post some example code which demonstrates the problem? |
Ah, I think maybe I understand. Django 3.1 adds new behaviour whereby you can use a relative path in |
Confirmed fixed with Whitenoise 0.5.2 |
Whitenoise breaks subpath behavior in production (but works in debug) with Django 3.1.
Django 3.1 lets you serve django from subpaths more easily by correctly prefixing static urls (e.g. https://my.big.site/mysmallapp/)
In Django 3.1 static urls are prefixed if there is a url path prefix specified by settings (FORCE_SCRIPT_NAME) or, more likely, from the webserver. This prefix is often delivered by the
script_name
wsgi variable or theroot_path
asgi variable and stored in django.urls.base._prefixes.The issue seems to occur here:
whitenoise/whitenoise/base.py
Lines 80 to 83 in 7161a8f
The find_file() function ends up with a code path that correctly prefixes the static file, while the files.get() code path does not.
Workaround right now is just to manually set
WHITENOISE_AUTOREFRESH = True
in production. The side effects from this are not terrible.But the expected behavior in Django 3.1 would be for this to work when AUTOREFRESH is False.
Django 3.1 is expected to release August 4, 2020.
django.urls.get_script_prefix() will supply the prefix, but its more likely that the path should come from some existing django static method.
The text was updated successfully, but these errors were encountered: