Opened 4 years ago
Closed 4 years ago
#31897 closed Cleanup/optimization (invalid)
Example in `Using settings in Python code` documentation is misleading
Reported by: | Garrett Edel | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 3.1 |
Severity: | Normal | Keywords: | settings, documentation |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The current example (https://docs.djangoproject.com/en/3.1/topics/settings/#using-settings-in-python-code) for how to use from django.conf import settings
includes the example of using settings.DEBUG
.
The example is fine, but if a user tries to replicate this in their test scripts settings.DEBUG
will always return False
as intended in the design of Django tests (https://docs.djangoproject.com/en/3.1/topics/testing/overview/#other-test-conditions). This PR simply adds an admonition in the docs to warn users about this and offer an alternative with override_settings().
Thanks for this ticket, however I don't see anything misleading in these examples. IMO we shouldn't mix an example of using settings in Python code (which is not a
DEBUG
docs) with a design decision about running tests withDEBUG =False
, it is beyond the scope of this paragraph.