Opened 8 years ago

Last modified 7 years ago

#25999 closed Cleanup/optimization

Document why Django makes its deprecation warnings loud by default and how to silence them — at Initial Version

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

Description

See #18985 for the background of why we route warnings through logging.

A developer can selectively silence warnings using something like this in an app's AppConfig.ready() method:

import warnings
from django.utils.deprecation import RemovedInNextVersionWarning
warnings.simplefilter("ignore", RemovedInNextVersionWarning)

This example can be improved to show how to silence a particular warning instead of all warnings.

This works because AppConfig.ready() methods are called after django.utils.log.configure_logging() (which does warnings.simplefilter("default", RemovedInNextVersionWarning)) in django.setup().

Change History (0)

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