#36562: `StaticFilesStorage` should respect `base_url` and treat `STATIC_URL` 
as a
fallback
-------------------------------------+-------------------------------------
     Reporter:  Kamil PaduszyƄski    |                     Type:
                                     |  Uncategorized
       Status:  new                  |                Component:
                                     |  contrib.staticfiles
      Version:  5.2                  |                 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
-------------------------------------+-------------------------------------
 As follows from the official
 
[https://docs.djangoproject.com/en/5.2/ref/files/storage/#django.core.files.storage.FileSystemStorage.base_url
 docs] one can specify `base_url` in storage's `"OPTIONS"`.
 `StaticFilesStorage` subclasses from `FileSystemStorage`, so one could
 expect that when setting:

 {{{#!python
 # Storages

 STORAGES = {
     "staticfiles": {
         "BACKEND":
 "django.contrib.staticfiles.storage.StaticFilesStorage",
         "OPTIONS": {
             "base_url": "static/",
         },
     },
 }
 }}}

 everything should work without touching `STATIC_URL`. However, we get:

 {{{
 django.core.exceptions.ImproperlyConfigured: You're using the staticfiles
 app without having set the required STATIC_URL setting.
 }}}

 Would it be possible to change this behavior? IMHO, such change would make
 setting up storages (even in development) more centralized, thus cleaner.
 Of course, this would not be a breaking change, since `STATIC_URL` could
 be still returned when `base_url` is not explicitly set.

 I believe that this would require updating `get_base_url` method of the
 static files handler mixin:

 
https://github.com/django/django/blob/ad4a9e0f3b1de261409bc083aa49dba705531824/django/contrib/staticfiles/handlers.py#L29-L31
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36562>
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/01070198c297e2b0-888a66b1-9cb1-4f02-80bc-cc5f7e0ec195-000000%40eu-central-1.amazonses.com.

Reply via email to