#34028: Django 'static' template tag fails to generate URLs with SCRIPT_NAME 
prefix
-------------------------------------------+------------------------
               Reporter:  Stewart Adam     |          Owner:  nobody
                   Type:  Bug              |         Status:  new
              Component:  Template system  |        Version:  4.0
               Severity:  Normal           |       Keywords:
           Triage Stage:  Unreviewed       |      Has patch:  0
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  0
                  UI/UX:  0                |
-------------------------------------------+------------------------
 According to the docs, when MEDIA_URL and STATIC_URL are relative (now the
 default), SCRIPT_NAME should automatically be prepended to them when it is
 set to ensure that paths are generated correctly. This appears to work
 everywhere *except* when calling `{% static %}` in HTML templates.

 Best I can tell, when this functionality was first added, it appears that
 SCRIPT_NAME was evaluated every request:
 
https://github.com/django/django/commit/c574bec0929cd2527268c96a492d25223a9fd576

 Looking at this same file today, it appears that setting values are now
 cached in a dict. When the Django application initializes, it reads
 SCRIPT_NAME as / and so all subsequent uses of `{% static %}` are output
 without the current value of SCRIPT_NAME. This happens even if using a
 hardcoded FORCE_SCRIPT_NAME.

 url() appears to be unaffected by the same issue, so the net result is
 that links and redirects honor SCRIPT_NAME as expected, and static files
 are served using the SCRIPT_NAME prefix, but all output from HTML
 templates simply use `/static/...` for their links which causes all
 css/js/favicon/related media to fail to load with a 404.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34028>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018363149b41-822c7c14-aec1-43c4-99e4-1c294c3ff19a-000000%40eu-central-1.amazonses.com.

Reply via email to