Opened 9 years ago
Last modified 8 years ago
#25999 closed Cleanup/optimization
Document why Django makes its deprecation warnings loud by default and how to silence them — at Initial Version
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()
.
Note:
See TracTickets
for help on using tickets.