Typing Your Django Project in 2026
Django's lack of built-in type hints, due to its pre-dating Python's type system, makes type checking challenging despite available tools. Packages like django-stubs and django-types help but face issues with speed, compatibility, and lagging support for newer Django versions. Alternatives like Django-Mantle propose avoiding Django's dynamic types altogether by using typed classes for business logic.
- ▪django-stubs provides type stubs and a mypy plugin but can be slow, especially for large Django applications.
- ▪Newer type checkers like pyright, ty, and pyrefly are faster but do not support django-stubs' plugin, leading to false positive errors.
- ▪django-types is a fork of django-stubs without the mypy plugin and requires explicit field definitions to avoid type errors.
- ▪Django-Mantle, released in September 2025, avoids dynamic typing by using attrs classes populated via Query helpers.
- ▪Django itself does not include type hints in its codebase, a decision made six years ago due to Python's evolving type system.
Opening excerpt (first ~120 words) tap to expand
12 Mar 2026Typing Your Django Project in 2026The first version of Django was released about 10 years before Python standardized its type hints syntax. Because of this it’s not surprising that getting type hints to work in your Django project is not going to be trivial.django-stubs with mypyIf you want your Django codebase to be type checked then django-stubs is the go to package to use. It ships both type-stubs for most of Django’s public APIs as well as a mypy plugin that fills in the typing information for all the dynamic black magic that we love Django for. You’ll also want to include the monkeypatch from django-stubs-ext for best results.This works but it’s kinda slow.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at Anže's Blog.