All you need to do is add htmlmin.middleware.HtmlMinifyMiddleware to your MIDDLEWARE_CLASSES :

Excluding some URLs

If you don’t want to minify all views in your app and it’s under a /my_app URL, you can tell the middleware to not minify the response of your views by adding a EXCLUDE_FROM_MINIFYING setting on your settings.py:

EXCLUDE_FROM_MINIFYING = ('^my_app/', '^admin/')