#34829: Django reports the “mutually exclusive” error for settings that do not
contain STATICFILES_STORAGE.
-------------------------------------+-------------------------------------
     Reporter:  Malik A. Rumi        |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  File                 |                  Version:  4.2
  uploads/storage                    |               Resolution:
     Severity:  Normal               |  worksforme
     Keywords:  mutually exclusive   |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => worksforme


Old description:

> There is no STATICFILES_STORAGE constant in my settings module. I took a
> look at the bytecode in pycache. There was no reference to
> STATICFILES_STORAGE there, either, but I did see a reference to
> STATICFILES_DIRS. I deleted all __pycache__ files and their folders, but
> the same identical error persisted.
>
> I looked at the source code that was generating the error:
>
>       python3.11/site-packages/django/conf/__init__.py
>
> specifically, line 278, which happens to be inside the definition of a
> class Settings.
>
>         if self.is_overridden("STATICFILES_STORAGE"):
>             if self.is_overridden("STORAGES"):
>                 raise ImproperlyConfigured(
>                     "STATICFILES_STORAGE/STORAGES are mutually
> exclusive."
>                 )
> The assumption seems to be that if both are overridden the dev is using
> both of them, and hence the error. Because I use white noise, it makes
> sense that STORAGES has been overridden. But since I have no reference to
> STATICFILES_STORAGE anywhere, it follows that the default value of
> global_settings is being inherited in my local settings, thus generating
> the error.
>
> django/django/conf/global_settings.py, line 630:
>
> STATICFILES_STORAGE =
> "django.contrib.staticfiles.storage.StaticFilesStorage"
>
> The problem here is that on line 274 of the same file, we have:
>
> STORAGES = {
>     "default": {
>         "BACKEND": "django.core.files.storage.FileSystemStorage",
>     },
>     "staticfiles": {
>         "BACKEND":
> "django.contrib.staticfiles.storage.StaticFilesStorage",
>     },
> }
>
> Are these constants mutually exclusive for everything ''but''
> global_settings? I commented the entire block:
>
>             # if self.is_overridden("STATICFILES_STORAGE"):
>             #     if self.is_overridden("STORAGES"):
>             #         raise ImproperlyConfigured(
>             #             "STATICFILES_STORAGE/STORAGES are mutually
> exclusive."
>             #         )
>             #     warnings.warn(STATICFILES_STORAGE_DEPRECATED_MSG,
> RemovedInDjango51Warning)
>

> And that worked:
>         (chronicle-jltMOQ-O-py3.11)
> malikarumi@Tetuoan2:~/Projects/lifeandtimes/chronicle$ python manage.py
> runserver
>         Watching for file changes with StatReloader
>         Performing system checks...
>
>         System check identified no issues (0 silenced).

New description:

 There is no STATICFILES_STORAGE constant in my settings module. I took a
 look at the bytecode in pycache. There was no reference to
 STATICFILES_STORAGE there, either, but I did see a reference to
 STATICFILES_DIRS. I deleted all __pycache__ files and their folders, but
 the same identical error persisted.

 I looked at the source code that was generating the error:

       python3.11/site-packages/django/conf/__init__.py

 specifically, line 278, which happens to be inside the definition of a
 class Settings.
 {{{
         if self.is_overridden("STATICFILES_STORAGE"):
             if self.is_overridden("STORAGES"):
                 raise ImproperlyConfigured(
                     "STATICFILES_STORAGE/STORAGES are mutually exclusive."
                 )
 }}}
 The assumption seems to be that if both are overridden the dev is using
 both of them, and hence the error. Because I use white noise, it makes
 sense that STORAGES has been overridden. But since I have no reference to
 STATICFILES_STORAGE anywhere, it follows that the default value of
 global_settings is being inherited in my local settings, thus generating
 the error.
 {{{
 django/django/conf/global_settings.py, line 630:

 STATICFILES_STORAGE =
 "django.contrib.staticfiles.storage.StaticFilesStorage"
 }}}
 The problem here is that on line 274 of the same file, we have:
 {{{
 STORAGES = {
     "default": {
         "BACKEND": "django.core.files.storage.FileSystemStorage",
     },
     "staticfiles": {
         "BACKEND":
 "django.contrib.staticfiles.storage.StaticFilesStorage",
     },
 }
 }}}
 Are these constants mutually exclusive for everything ''but''
 global_settings? I commented the entire block:
 {{{
             # if self.is_overridden("STATICFILES_STORAGE"):
             #     if self.is_overridden("STORAGES"):
             #         raise ImproperlyConfigured(
             #             "STATICFILES_STORAGE/STORAGES are mutually
 exclusive."
             #         )
             #     warnings.warn(STATICFILES_STORAGE_DEPRECATED_MSG,
 RemovedInDjango51Warning)
 }}}

 And that worked:
 {{{
         (chronicle-jltMOQ-O-py3.11)
 malikarumi@Tetuoan2:~/Projects/lifeandtimes/chronicle$ python manage.py
 runserver
         Watching for file changes with StatReloader
         Performing system checks...

         System check identified no issues (0 silenced).
 }}}

--

Comment:

 Thanks for the report, however it works for me. Perhaps 3rd-party packages
 defines both settings. Check TicketClosingReasons/UseSupportChannels for
 ways to get help, folks on support channels can help you debug your issue.

 > Are these constants mutually exclusive for everything but
 global_settings?

 Exactly.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34829#comment:1>
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/0107018a856cf88b-1b93b4dd-9bd6-4c34-a43d-325dc0e026b7-000000%40eu-central-1.amazonses.com.

Reply via email to