django-stubs
django-stubs copied to clipboard
PEP-484 stubs for Django
# Bug report ## What's wrong When defining managers with a custom queryset, the typing of said queryset is lost. Instead of having `MyQuerySet` we have `QuerySet[MyModel, MyModel]`. This happens...
# Enhancement ## What's wrong The current type stubs define the `authenticate` method of the `ModelBackend` (`django.contrib.auth.backends.ModelBackend`) as such: ```py def authenticate( self, request: HttpRequest | None, username: str |...
Suggested by @charettes on [a Django forum discussion](https://forum.djangoproject.com/t/revisiting-types-in-django-dep-14/37832/11) regrading adding types to Django: ```py from __future__ import annotations from typing import Protocol from django.db.models import fields from django.db.models.sql import compiler,...
this is similar to `.annotate` but slightly different / more manual querying an example from some sentry code: ```python commit_results = list( Commit.objects.extra( select={"group_id": "sentry_grouplink.group_id"}, tables=["sentry_grouplink"], where=[ "sentry_grouplink.linked_id = sentry_commit.id",...
Hello! In #2004, the return type of `ListFilter.choices` was changed to use a private `TypedDict`. However, since `TypedDict` is not a subclass of `dict`, this introduces extra friction when implementing...
I'm currently implementing a custom static files finder, and have been running into type errors when testing on the first alpha release of Django 5.2. Looks like in 5.2, the...
# Bug report Starting from django-stubs 5.0.3, the following example crashes with an internal mypy error: ```py from django.db import models import typing as t TMyBase = t.TypeVar("TMyBase", bound="MyBase") class...
Hi, first of all, thank you for this awesome project, but I have some questions. I see there's _MonkeyPatchedWSGIResponse, but I've no idea how I'm supposed to use it I...
# Bug report I'm adding type hints to a rather large Django project with a custom user model, discovered a bug after upgrading to Django 5.1.4. ## What's wrong ```...
Currently most `get()` methods in `django-stubs` return `HttpResponse`, except for `RedirectView`, which returns `HttpResponseBase`. I'm wondering if it would be better to have all `get()` methods return `HttpResponseBase`. `StreamingHttpResponse` and...