#34028: Django 'static' template tag fails to generate URLs with SCRIPT_NAME
prefix
---------------------------------+---------------------------------------
Reporter: Stewart Adam | Owner: Sarah Boyce
Type: Bug | Status: closed
Component: Template system | Version: dev
Severity: Normal | Resolution: invalid
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 Klaas van Schelven):
IMHO this (or something awefully close to it) is _still_ a bug.
1. From the 3.1 release notes:
https://docs.djangoproject.com/en/3.1/releases/3.1/#backwards-
incompatible-3-1
> The STATIC_URL and MEDIA_URL settings set to relative paths are now
prefixed by the server-provided value of SCRIPT_NAME (or / if not set).
This change should not affect settings set to valid URLs or absolute
paths.
As per the original commit message
https://github.com/django/django/commit/c574bec0929cd2527268c96a492d25223a9fd576
and in my personal opinion this also makes perfect sense... this brings
the behavior of "static" inline with that of e.g. "reverse".
2. when running the django runserver with autoreload, STATIC_URL appears
to be evaluated outside the request/response cycle (and then cached)...
this is behavior that is dicussed in this issue... I'm not sure I
personally fully understand it (haven't dived into it deeply enough). But
what I do understand is: I'm not doing the thing that's been described as
"don't do this". Nor am I using whitenoise. But I am suffering from
exactly this problem (in Django 5.2).
here's a repo that shows the problem:
https://github.com/vanschelven/poc34028
when visiting in the browser I get:
static: /static/hallo
reverse: /scriptname/
but I would expect the line with "static" to also say
"/scriptname/static/hallo"
--
Ticket URL: <https://code.djangoproject.com/ticket/34028#comment:15>
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 visit
https://groups.google.com/d/msgid/django-updates/010701991b4cf3ca-c269a95e-ab68-48f1-b3ef-89bd4e1d7acd-000000%40eu-central-1.amazonses.com.