#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           |               Resolution:
     Keywords:                   |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+--------------------------------------

Comment (by Stewart Adam):

 The code path leading to the issue appears to be:

 1. `static()` handler for the template tag calls
 `StaticNode.handle_simple()` in
 [https://github.com/django/django/blob/main/django/templatetags/static.py#L174
 templatetags/static.py L174]
 2. `StaticNode.handle_simple()` calls `staticfiles_storage.url()` at
 [https://github.com/django/django/blob/main/django/templatetags/static.py#L127
 templatetags/static.py L127]
 3. `staticfiles_storage.url()` is backed by a `FileSystemStorage`:
 [https://github.com/django/django/blob/main/django/core/files/storage.py#L392
 core/files/storage.py L392]

 None of these calls attempt to verify `SCRIPT_NAME` or inject
 `STATIC_URL`. An
 [https://github.com/django/django/blob/main/django/templatetags/static.py#L131
 alternate code path] during step 2 *does* appear to inject `STATIC_URL`.
 however to due application settings now being cached into a dict/module
 the value does not reflect the current value of `SCRIPT_NAME` and uses the
 value at application initialization (empty string) instead, so STATIC_URL
 is always just `/static/`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34028#comment:2>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701836352d44d-009e9f74-1d0c-4291-b0d7-6018b5929b45-000000%40eu-central-1.amazonses.com.

Reply via email to