django-coverage-plugin
Django template coverage.py plugin
What it is and what it does
django-coverage-plugin extends coverage.py to track which lines of your Django HTML templates are executed during testing. Rather than treating templates as unmeasured code, it hooks into Django's template debugging system to record which template lines ran, which didn't, and which were conditionally skipped. You configure it by adding a single line to your .coveragerc file, then run your tests normally under coverage.py—templates appear in your coverage report just like Python modules.
The plugin requires Django templates to have debugging enabled (TEMPLATES.OPTIONS.debug = True) and works with Django 5.2 through 6.0 on Python 3.10 through 3.14. It can also discover unused template files in your templates directory and include them in results. Configuration supports filtering by file extension and respects standard coverage.py settings like source, include, and omit.
Use it for:
- Measure test coverage of Django template rendering to identify untested template branches and conditional blocks
- Discover unused template files in your project that can be safely removed
- Enforce minimum coverage thresholds for templates as part of CI/CD pipelines
- Debug template execution paths by seeing which lines ran during specific test cases
- Generate unified coverage reports combining Python and template coverage metrics
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A coverage.py plugin that measures test coverage of Django templates, integrating template execution tracking into your coverage reports alongside Python code coverage.
Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and solves a real gap in Django testing—template coverage is otherwise invisible to standard coverage.py. Install it if you use Django templates and want to measure test coverage comprehensively. The only gotcha is the requirement to enable template debugging in settings, which is documented clearly.
Install
django-coverage-plugin on PyPI
pip
pip install django-coverage-pluginuv
uv add django-coverage-pluginpoetry
poetry add django-coverage-pluginInstalling django-coverage-plugin
Before you install
Low install friction with a wheel distribution. Actively maintained as of 2026-04-04, with recent fixes for template line reporting and support for Django 5.2 and 6.0. Requires only coverage and Django as runtime dependencies.
License in practice
Licensed under Apache-2.0 (permissive), allowing use in commercial and proprietary projects with minimal restrictions beyond attribution.
Quickstart
pip install django-coverage-plugin
# Add to .coveragerc:
# [run]
# plugins = django_coverage_plugin
# Then run:
coverage run --source='.' manage.py test
coverage report
DJANGO_SETTINGS_MODULE environment variable must be set, and TEMPLATES.OPTIONS.debug must be True in your Django settings for template coverage to work.
Verify before relying
- Whether template coverage accuracy varies significantly across different Django template tag libraries or custom tags
- Performance impact on large projects with hundreds or thousands of templates
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — coverage, Django |
| Maintenance | actively maintained — 132 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,057,576/month — #4,430 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_coverage_plugin-3.2.2-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
coverage_enable_subprocessInstalls a .pth file that automatically enables…
permissive · top 15,000 on PyPI
coverage-conditional-pluginA coverage.py plugin that applies conditional…
permissive · top 15,000 on PyPI
pytest-djangopytest-django integrates Django with pytest,…
permissive · top 1,000 on PyPI
covdefaultsA coverage plugin that automatically applies…
permissive · top 15,000 on PyPI
coverallsUploads Python test coverage reports to…
permissive · top 5,000 on PyPI
slipcoverSlipCover is a fast code coverage tool that…
permissive · top 15,000 on PyPI
pytest-coverpytest-cover is a pytest plugin for measuring…
permissive · top 15,000 on PyPI
coverage-badgeGenerates SVG coverage badges from Coverage.py…
permissive · top 15,000 on PyPI
django-health-checkProvides pluggable health check endpoints for…
permissive · top 5,000 on PyPI