#34773: settings.STATICFILES_STORAGE does not return correct value when STORAGES
are defined
--------------------------------------+------------------------------------
     Reporter:  Petr DlouhĂ˝           |                    Owner:  nobody
         Type:  Bug                   |                   Status:  new
    Component:  contrib.staticfiles   |                  Version:  4.2
     Severity:  Release blocker       |               Resolution:
     Keywords:  storages staticfiles  |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by Mariusz Felisiak):

 Petr, Does the following patch work for you?
 {{{#!diff
 diff --git a/django/conf/__init__.py b/django/conf/__init__.py
 index da461ecc02..09ba791f6b 100644
 --- a/django/conf/__init__.py
 +++ b/django/conf/__init__.py
 @@ -217,18 +217,20 @@ class Settings:
              os.environ["TZ"] = self.TIME_ZONE
              time.tzset()

 -        if self.is_overridden("DEFAULT_FILE_STORAGE"):
 -            if self.is_overridden("STORAGES"):
 +        if self.is_overridden("STORAGES"):
 +            if self.is_overridden("DEFAULT_FILE_STORAGE"):
                  raise ImproperlyConfigured(
                      "DEFAULT_FILE_STORAGE/STORAGES are mutually
 exclusive."
                  )
 -            warnings.warn(DEFAULT_FILE_STORAGE_DEPRECATED_MSG,
 RemovedInDjango51Warning)
 -
 -        if self.is_overridden("STATICFILES_STORAGE"):
 -            if self.is_overridden("STORAGES"):
 +            if self.is_overridden("STATICFILES_STORAGE"):
                  raise ImproperlyConfigured(
                      "STATICFILES_STORAGE/STORAGES are mutually
 exclusive."
                  )
 +            setattr(self, 'DEFAULT_FILE_STORAGE',
 self.STORAGES.get(DEFAULT_STORAGE_ALIAS, {}).get("BACKEND"))
 +            setattr(self, 'STATICFILES_STORAGE',
 self.STORAGES.get(STATICFILES_STORAGE_ALIAS, {}).get("BACKEND"))
 +        if self.is_overridden("DEFAULT_FILE_STORAGE"):
 +            warnings.warn(DEFAULT_FILE_STORAGE_DEPRECATED_MSG,
 RemovedInDjango51Warning)
 +        if self.is_overridden("STATICFILES_STORAGE"):
              warnings.warn(STATICFILES_STORAGE_DEPRECATED_MSG,
 RemovedInDjango51Warning)

      def is_overridden(self, setting):

 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34773#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 on the web visit 
https://groups.google.com/d/msgid/django-updates/01070189edcc7bc2-4aed1b5f-3440-41b1-b927-85369535bbdf-000000%40eu-central-1.amazonses.com.

Reply via email to