--- id: django-types version: "0.24.0" license: MIT license_treatment: permissive maintenance: active --- # django-types — Type stubs for Django License: permissive · Maintenance: active · Downloads: 1.1M/mo ## What it is and what it does django-types is a type stub package that adds static type information for Django, enabling type checkers like mypy and pyright to understand Django's API. It was forked from django-stubs specifically to remove the mypy plugin dependency, which means it works with multiple type checkers and avoids crashes caused by Django configuration issues. The package helps developers annotate Django models, querysets, managers, and HTTP request objects with proper types. It includes guidance for common patterns like foreign key relationships, related managers, and authenticated request handlers. Since Django's ORM classes don't support runtime subscripting (e.g., QuerySet[MyModel]), the stubs document workarounds using string annotations or a companion monkeypatch utility. Use it for: - Add type hints to Django ORM models so foreign keys and related managers are properly typed for IDE autocomplete and type checking - Enable pyright or other non-mypy type checkers to validate Django code without plugin crashes - Annotate view functions with typed HttpRequest subclasses to enforce authentication requirements at the type level - Catch type errors in Django querysets and manager calls during development rather than at runtime ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides type stubs for Django to enable static type checking with mypy, pyright, and other type checkers without requiring a mypy plugin. Yes. django-types is actively maintained, has no known vulnerabilities, low install friction, and is essential for any Django project using static type checking. The MIT license is permissive. Install it if you use type checkers with Django; it's a standard practice for modern Django development. ## Install pip install django-types uv add django-types poetry add django-types ## Installing django-types Before you install: Low install friction with a single runtime dependency (types-psycopg2). Actively maintained with recent releases; last commit 2026-06-23 and latest release 2026-04-22. License in practice: MIT license permits commercial and private use with minimal restrictions; suitable for most projects. Quickstart: pip install django-types # In your Django model: from typing import Optional from django.db import models class User(models.Model): team_id: Optional[int] team = models.ForeignKey('Team', null=True, on_delete=models.SET_NULL) Requires Python 3.10 or later. QuerySet and Manager generics do not support subscripting at runtime; use string annotations or django_stubs_ext.monkeypatch() as a workaround. Verify before relying: - Whether type coverage is complete for all Django ORM features and edge cases - Performance impact of type checking with these stubs on typical Django projects ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags django type stubs, django type checking, django mypy types, django pyright support, django static typing, django type hints, django orm type annotations, type-stubs, django, static-typing [View on SkillFed](https://skillfed.io/packages/django-types) · [View on PyPI](https://pypi.org/project/django-types/)