Django deprecation warnings and 3rd-party libraries

How and why you should selectively ignore warnings from 3rd party python libraries.


Django's deprecation warnings, and Python warnings in general, are pretty useful, alerting you to changes you'll need to make to your code well in advance of anything actually breaking. If you haven't already, you should turn them on:


Or from the command line:

python -Wd

Now you'll see warnings like this when you run your script or app:

DeprecationWarning: Positional arguments are deprecated in Markdown.
Use keyword arguments only.

The downside is that this can lead to an overload of warnings from code you have no direct control of, i.e. 3rd-party Django libraries, and the warnings in your own code, that you can fix, can easily be lost in the noise.

Hide warnings you can't control

Rather than require every 3rd-party library maintainer to keep on top of this (or merge your pull requests) you can set python to selectively ignore warnings, based on the module they originate from.

In a django app, add the following to your

import warnings
IGNORE_MODULES = 'easy_thumbnails|webpack_loader'
warnings.filterwarnings("ignore", module=IGNORE_MODULES)

This will stop any django warnings from the specified libraries from appearing in the shell. Note that IGNORE_MODULES is just a regex, so you can match the originating module any way you like. In this example I'm ignoring all warnings from Easy thumbnails but you could just ignore warnings from easy_thumbnails.models by changing

IGNORE_MODULES = 'easy_thumbnails|webpack_loader'


IGNORE_MODULES = 'easy_thumbnails\.models|webpack_loader'

Finally, note that just because a warning originates from a 3rd-party library doesn't mean it's not a potential issue. Suppressing 3rd-party warnings makes it less painful to keep your own code up to date, but you'll still need to check periodically to make sure your libraries are up to date.