[Django] #36635: Settings._explicit_settings attribute not accessible when using override_settings

5 views
Skip to first unread message

Django

unread,
Oct 1, 2025, 11:35:30 PM (4 days ago) Oct 1
to django-...@googlegroups.com
#36635: Settings._explicit_settings attribute not accessible when using
override_settings
-----------------------+---------------------------------------------
Reporter: mmdev | Type: Uncategorized
Status: new | Component: Testing framework
Version: 5.2 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------+---------------------------------------------
The `Settings._explicit_settings` attribute, which is always populated by
`Settings.__init__()`, becomes inaccessible when the `override_settings`
decorator or context manager is used. This causes an `AttributeError` when
trying to access this attribute, creating inconsistent behavior.

== Steps to Reproduce

As a decorator:
{{{#!python
from django.test import override_settings

@override_settings(KEY="VALUE")
def test_override_settings(settings):
assert settings._explicit_settings # Raises AttributeError
}}}

As a context manager:
{{{#!python
from django.test import override_settings
from django.conf import settings

with override_settings(KEY="VALUE"):
settings._explicit_settings # Raises AttributeError
}}}

Both cases raise `AttributeError: '_explicit_settings'` but work correctly
without `override_settings`.

== Expected Behavior

The behavior should be consistent: if `_explicit_settings` is accessible
without `override_settings`, it should remain accessible when using
`override_settings` (both as a decorator and context manager). This
attribute is an internal part of the Settings API and may be needed by
test code to inspect which settings were explicitly set in the settings
module.
--
Ticket URL: <https://code.djangoproject.com/ticket/36635>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 1, 2025, 11:36:34 PM (4 days ago) Oct 1
to django-...@googlegroups.com
#36635: Settings._explicit_settings attribute not accessible when using
override_settings
-----------------------------------+--------------------------------------
Reporter: mmdev | Owner: (none)
Type: Uncategorized | Status: new
Component: Testing framework | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+--------------------------------------
Description changed by mmdev:

Old description:
New description:

The `Settings._explicit_settings` attribute, which is always populated by
`Settings.__init__()`, becomes inaccessible when the `override_settings`
decorator or context manager is used. This causes an `AttributeError` when
trying to access this attribute, creating inconsistent behavior.

== Steps to Reproduce

As a decorator:
{{{#!python
from django.test import override_settings
from django.conf import settings

@override_settings(KEY="VALUE")
def test_override_settings(settings):
assert settings._explicit_settings # Raises AttributeError
}}}

As a context manager:
{{{#!python
from django.test import override_settings
from django.conf import settings

with override_settings(KEY="VALUE"):
settings._explicit_settings # Raises AttributeError
}}}

Both cases raise `AttributeError: '_explicit_settings'` but work correctly
without `override_settings`.

== Expected Behavior

The behavior should be consistent: if `_explicit_settings` is accessible
without `override_settings`, it should remain accessible when using
`override_settings` (both as a decorator and context manager). This
attribute is an internal part of the Settings API and may be needed by
test code to inspect which settings were explicitly set in the settings
module.

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36635#comment:1>

Django

unread,
Oct 3, 2025, 1:54:57 AM (3 days ago) Oct 3
to django-...@googlegroups.com
#36635: Settings._explicit_settings attribute not accessible when using
override_settings
-----------------------------------+--------------------------------------
Reporter: mmdev | Owner: (none)
Type: Uncategorized | Status: closed
Component: Testing framework | Version: 5.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

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

Comment:

`_explicit_settings` is an undocumented, internal, implementation detail.
You should not rely on it.
--
Ticket URL: <https://code.djangoproject.com/ticket/36635#comment:2>
Reply all
Reply to author
Forward
0 new messages