#36562: `StaticFilesStorage` should respect `base_url` and treat `STATIC_URL`
as a
fallback
-------------------------------------+-------------------------------------
Reporter: Kamil Paduszyński | Owner: (none)
Type: Bug | Status: closed
Component: contrib.staticfiles | Version: 5.2
Severity: Normal | Resolution:
| worksforme
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 Kamil Paduszyński):
Sorry for misunderstanding. Let me explain it in more detail.
Setting `STATIC_URL=None` and putting the actual URL into `base_url`
options results in passing system checks (the `check` command).
The mentioned error is raised when I execute the `runserver` command (the
one overloaded from the `staticfiles` app). Your tests don't account for
running commands, I guess. I also checked that the problem (I don't want
to call that a bug for now) raises only in debugging mode `DEBUG = True`.
Sample project: https://github.com/paduszyk/ticket_36562.
My tests:
{{{#!python
from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
from django.test import TestCase
from django.test.utils import override_settings
@override_settings(
DEBUG=True,
STORAGES={
"staticfiles": {
"BACKEND":
"django.contrib.staticfiles.storage.StaticFilesStorage",
"OPTIONS": {
"base_url": "static/",
},
},
},
STATIC_URL=None,
)
class TestStoragesIfBaseURLandStaticURLNone(TestCase):
def test_check_does_not_raise_error(self):
try:
call_command("check")
except Exception:
self.fail()
def test_runserver_raises_improperly_configured(self):
with self.assertRaises(ImproperlyConfigured):
call_command("runserver", "--noreload")
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36562#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 [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070198c3bd7fd0-3320546c-cb5b-4ff4-858c-ac2cbdbdec53-000000%40eu-central-1.amazonses.com.