Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#15336 closed (fixed)

Spurious DeprecationWarning when no database settings present

Reported by: isagalaev Owned by: isagalaev
Component: Core (Other) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

If a db-less project doesn't set up database settings management commands produce a spurious DeprecationWarning:

django/db/__init__.py:18: DeprecationWarning: settings.DATABASE_* is deprecated; use settings.DATABASES instead.
  DeprecationWarning

This breaks running cron scripts due to cron considering any output from a program as a reason to yell into your email about something possibly broken.

The warning is raised on a single condition of empty settings.DATABASES. This is easily fixed by also checking if a deprecated settings.DATABASE_ENGINE is set. A patch is following.

Attachments (2)

15336.diff (743 bytes) - added by isagalaev 5 years ago.
Patch
__init__.py (4.2 KB) - added by anonymous 3 years ago.

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by isagalaev

Patch

comment:1 Changed 5 years ago by isagalaev

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I'm not really sure how to write a test for this because tests require database settings. However the fix seems to be pretty trivial and may be we could leave out tests in this case.

comment:2 Changed 5 years ago by russellm

  • Component changed from Uncategorized to Core framework
  • Triage Stage changed from Unreviewed to Ready for checkin

This is inherently difficult to test, so I'm happy to accept this RFC based on inspection and manual testing.

comment:3 Changed 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

In [15571]:

Fixed #15336 -- Silenced a warning about the DATABASES transition when a database backend isn't specified. Thanks to Ivan Sagalaev for the report and patch.

comment:4 Changed 5 years ago by russellm

In [15575]:

[1.2.X] Fixed #15336 -- Silenced a warning about the DATABASES transition when a database backend isn't specified. Thanks to Ivan Sagalaev for the report and patch.

Backport of r15571 from trunk.

Changed 3 years ago by anonymous

Note: See TracTickets for help on using tickets.
Back to Top