After upgrading from django 1.3 to django 1.5 I started to see these DeprecationWarnings
during the test run:
path_to_virtualenv/lib/python2.6/site-packages/django/http/request.py:193: DeprecationWarning: HttpRequest.raw_post_data has been deprecated. Use HttpRequest.body instead.
I've searched inside the project for raw_post_data
and found nothing. So it was not directly used in the project. Then, I've manually went through INSTALLED_APPS
and found that raven
module still uses raw_post_data
and it was the cause, but..
Is it possible to see the cause of DeprecationWarning
during the test run? How to make these warnings more verbose?
Deprecation warnings are a common thing in our industry. They are warnings that notify us that a specific feature (e.g. a method) will be removed soon (usually in the next minor or major version) and should be replaced with something else.
removing is danger because user may used that and if a developer want to remove a thing first have to notify others to don't use this feature or things and after this he can remove. and DeprecationWarning is this notification.
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 test
python -W error::DeprecationWarning manage.py test
python -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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With