Description
(last modified by Rostyslav Bryzgunov)By default, {% static '...' %} tag just appends STATIC_URL in the path. When running on sub-path, using SCRIPT_NAME WSGI param, it results in incorrect static URL - it doesn't prepend SCRIPT_NAME prefix.
This problem can be solved with prepending SCRIPT_NAME to STATIC_URL in settings.py but that doesn't work when SCRIPT_NAME is a dynamic value.
This can be easily added into default Django static tag and django.contrib.staticfiles tag as following:
def render(self, context):
url = self.url(context)
# Updating url here with request.META['SCRIPT_NAME']
if self.varname is None:
return url
context[self.varname] = url
return ''
On more research I found that FileSystemStorage and StaticFilesStorage ignores SCRIPT_NAME as well.
We might have to do a lot of changes but I think it's worth the efforts.
580e644f24f1 (django/django 3.1), dependencies installed and tests runnable from the first minute. You are graded by hidden tests taken from the fix that was actually merged upstream.