[Django] #29236: diffsettings raises misleading exception message if using settings.configure

25 views
Skip to first unread message

Django

unread,
Mar 18, 2018, 12:48:01 PM3/18/18
to django-...@googlegroups.com
#29236: diffsettings raises misleading exception message if using
settings.configure
-------------------------------------+-------------------------------------
Reporter: Keryn | Owner: nobody
Knight |
Type: Bug | Status: new
Component: Core | Version: master
(Management commands) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
If, rather than using the env var `DJANGO_SETTINGS_MODULE` one uses
`settings.configure(...)`, attempting to call diffsettings can fail
because it calls `settings._setup()` unconditionally, with the exception
{{{
django.core.exceptions.ImproperlyConfigured: Requested settings, but
settings are not configured. You must either define the environment
variable DJANGO_SETTINGS_MODULE or call settings.configure() before
accessing settings.
}}}
were the call instead:
{{{
if not settings.configured:
settings._setup()
}}}
things would work correctly.

--
Ticket URL: <https://code.djangoproject.com/ticket/29236>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 18, 2018, 12:48:12 PM3/18/18
to django-...@googlegroups.com
#29236: diffsettings raises misleading exception message if using
settings.configure
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) |
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
-------------------------------------+-------------------------------------
Changes (by Keryn Knight):

* cc: Keryn Knight (added)


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

Django

unread,
Mar 20, 2018, 11:56:34 AM3/20/18
to django-...@googlegroups.com
#29236: diffsettings raises misleading exception message if using
settings.configure()

-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: nobody
Type: Bug | Status: new

Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/29236#comment:2>

Django

unread,
Mar 22, 2018, 3:21:50 AM3/22/18
to django-...@googlegroups.com
#29236: diffsettings raises misleading exception message if using
settings.configure()
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Chris
| Mark
Type: Bug | Status: assigned

Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Chris Mark):

* owner: nobody => Chris Mark
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/29236#comment:3>

Django

unread,
Mar 22, 2018, 5:27:51 AM3/22/18
to django-...@googlegroups.com
#29236: diffsettings raises misleading exception message if using
settings.configure()
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Chris
| Mark
Type: Bug | Status: assigned
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Chris Mark):

* has_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

https://github.com/django/django/pull/9812

--
Ticket URL: <https://code.djangoproject.com/ticket/29236#comment:4>

Django

unread,
Mar 30, 2018, 4:05:48 AM3/30/18
to django-...@googlegroups.com
#29236: diffsettings raises misleading exception message if using
settings.configure()
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Chris
| Mark
Type: Bug | Status: assigned
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Chris Mark):

Keryn I found it difficult to add a test for the patch, since I cannot
find a proper way to create the environment needed to catch this case.

On
https://github.com/django/django/blob/master/tests/admin_scripts/tests.py#L2166,
the tests use a target settings file, and if it is not present the tests
will fail, so I need to configure somehow the settings, before(?)
executing the actual command.

Any proposal or insight?

Chris

--
Ticket URL: <https://code.djangoproject.com/ticket/29236#comment:5>

Django

unread,
Aug 18, 2018, 4:27:55 PM8/18/18
to django-...@googlegroups.com
#29236: diffsettings raises misleading exception message if using
settings.configure()
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Hasan
| Ramezani

Type: Bug | Status: assigned
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* owner: Chris Mark => Hasan Ramezani


--
Ticket URL: <https://code.djangoproject.com/ticket/29236#comment:6>

Django

unread,
Aug 18, 2018, 4:47:22 PM8/18/18
to django-...@googlegroups.com
#29236: diffsettings raises misleading exception message if using
settings.configure()
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/29236#comment:7>

Django

unread,
Aug 18, 2018, 4:54:04 PM8/18/18
to django-...@googlegroups.com
#29236: diffsettings raises misleading exception message if using
settings.configure()
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Hasan Ramezani):

PR [https://github.com/django/django/pull/10316]

--
Ticket URL: <https://code.djangoproject.com/ticket/29236#comment:8>

Django

unread,
Aug 20, 2018, 1:16:47 PM8/20/18
to django-...@googlegroups.com
#29236: diffsettings raises misleading exception message if using
settings.configure()
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Hasan
| Ramezani
Type: Bug | Status: closed

Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"49b679371fe9beddcd23a93b5fdbadea914f37f8" 49b6793]:
{{{
#!CommitTicketReference repository=""
revision="49b679371fe9beddcd23a93b5fdbadea914f37f8"
Fixed #29236 -- Fixed diffsettings crash if using settings.configure().
}}}

Reply all
Reply to author
Forward
0 new messages