django-stubs
Mypy stubs for Django
Decision gist · record as of 2026-08-14
Yes. If you use Django and mypy, this is essential. It transforms mypy from a tool that struggles with Django's dynamic patterns into one that catches real errors in model definitions, querysets, and views. The package is actively maintained, has no known vulnerabilities, and is permissively licensed. Install it as a development dependency with no runtime cost.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires mypy to be installed and configured; the plugin needs django_settings_module to be specified either in config or via DJANGO_SETTINGS_MODULE environment variable.
- Low friction installation as a pure Python wheel with straightforward dependencies.
- Actively maintained with a release 2 days ago.
License · maintenance · safety
MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects.
last release 2026-08-12 (2 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 11,148,392 downloads/mo, #1,414 on PyPI
Alternatives
Verify before relying
pip install django-stubs[compatible-mypy]
Then add to mypy.ini or pyproject.toml:
[mypy]
plugins = mypy_django_plugin.main
[mypy.plugins.django-stubs]
django_settings_module = "myproject.settings"- Whether the custom mypy plugin's advanced features beyond basic type stubs are documented or discoverable without reading source code.
- Performance impact of the mypy plugin on type-checking speed for large Django projects.
- Exact scope of support for pyright, pyrefly, and other type checkers beyond mypy.
What it is and what it does
django-stubs bridges the gap between Django's dynamic runtime behavior and static type checkers by providing type stubs and a custom mypy plugin. Django uses Python "magic" patterns that make precise type inference difficult; this package adds explicit type information so mypy can understand model fields, managers, querysets, and other framework patterns correctly.
The package is installed as a development dependency and does not affect runtime behavior—it only enhances the mypy type-checking process. It supports mypy with full advanced features, and provides basic support for pyright, pyrefly, and other type checkers. Configuration is minimal: add the plugin to your mypy config and specify your Django settings module, and type checking will immediately become more precise for common Django patterns.
Use it for
- Enable mypy to type-check Django model definitions, catching errors in field declarations and Meta class configurations before runtime.
- Provide type hints for QuerySet and Manager operations so IDE autocomplete and type checkers understand query results and method chains.
- Validate custom database routers and other Django components that inherit from typed base classes.
- Catch type errors in Django views and forms by giving type checkers knowledge of Django's request/response and form field types.
- Use TypedModelMeta to enforce correct types on model Meta attributes like ordering and constraints.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
If you use Django and mypy, this is essential. It transforms mypy from a tool that struggles with Django's dynamic patterns into one that catches real errors in model definitions, querysets, and views. The package is actively maintained, has no known vulnerabilities, and is permissively licensed. Install it as a development dependency with no runtime cost.
Install
django-stubs on PyPI
Before you install
Low friction installation as a pure Python wheel with straightforward dependencies. Actively maintained with a release 2 days ago.
Requires mypy to be installed and configured; the plugin needs django_settings_module to be specified either in config or via DJANGO_SETTINGS_MODULE environment variable.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects.
Quickstart
pip install django-stubs[compatible-mypy]
Then add to mypy.ini or pyproject.toml:
[mypy]
plugins = mypy_django_plugin.main
[mypy.plugins.django-stubs]
django_settings_module = "myproject.settings"
Verify before relying
- Whether the custom mypy plugin's advanced features beyond basic type stubs are documented or discoverable without reading source code.
- Performance impact of the mypy plugin on type-checking speed for large Django projects.
- Exact scope of support for pyright, pyrefly, and other type checkers beyond mypy.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.11 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 4 packagesdjangodjango-stubs-exttypes-pyyamltyping-extensions |
| Maintenance | Actively maintained 2 days since the last release |
| First released | |
| Downloads | 11,148,392 / month, #1,414 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Framework :: DjangoFramework :: Django :: 5.2Framework :: Django :: 6.0Framework :: Django :: 6.1Operating System :: OS IndependentProgramming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Typing :: Typed |
Evidence: django_stubs-6.1.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “mypy plugin django”
- django-stubsProvides type stubs and a mypy plugin to enable precise static type…
- djangorestframework-stubsProvides PEP-484 type stubs for Django REST Framework to enable mypy…
- django-typesProvides type stubs for Django to enable static type checking with…
Give your agent the search over MCP, or paste the wish link into any chat.
More Quality Assurance packages
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
Ruff is a Python linter and code formatter written in Rust that combines linting, formatting, and code fixing into a single tool, replacing Flake8, Black, isort, and related utilities.
Pexpect spawns and controls interactive console applications by sending input and matching output patterns, automating tasks that would otherwise require manual interaction.
Black reformats Python source code to a consistent style by parsing entire files and rewriting them according to an opinionated, deterministic set of rules, eliminating manual formatting decisions.
pytest-xdist distributes pytest tests across multiple CPU cores or machines to speed up test execution, with the simplest usage being `pytest -n auto` to spawn workers equal to available CPUs.
Install it if your test suite takes long enough that parallelization would save meaningful time.
Validates AWS CloudFormation templates in YAML or JSON format against resource provider schemas and best practices, checking property values and configuration correctness.
Install it if you work with CloudFormation templates.
See also django-stubs-ext · django-types · djangorestframework-types · sqlalchemy-stubs · djangorestframework-stubs · google-auth-stubs · django-localflavor · django-dirtyfields · google-api-python-client-stubs · mypy