Verbose deprecation warnings in Django Verbose deprecation warnings in Django django django

Verbose deprecation warnings in Django


You can set Python warning control by command line option -W to raise an exception with a traceback on DeprecationWarning like for errors instead of normal simple warning once. Any specific warning can by filtered by message, category, module, line or by a combination of them.

Examples:

python -W error:"raw_post_data has been deprecated" manage.py testpython -W error::DeprecationWarning manage.py testpython -W error:::django.http.request manage.py test

A fine filtering is useful if you want to fix all warnings of one type together by batch editing in many files of a big project.


Python 2.7 and higher ignores DeprecationWarning usually if they are not reanabled, e.g. by -Wd option or by the environment variable export PYTHONWARNINGS="d". That can be useful on development machines but not on production.


This is taken from a similar question.

You can use the warnings modules to raise an error for DeprecationWarning.

Temporarily add the following snippet to the top of your project's urls.py:

import warningswarnings.simplefilter('error', DeprecationWarning)

The DeprecationWarning will now raise an error, so if debug=True you'll get the familiar yellow Django error page with the full traceback.