django-stubs
django-stubs copied to clipboard
PEP-484 stubs for Django
# Bug report ## What's wrong Getting an error on a reasonable line in my test suite involving a `StreamingHttpResponse.streaming_content` in vscode / pylance and mypy. As long as the...
In `django.contrib.postgres.fields.ranges` the `Range` types are imported from [`psycopg2`](https://pypi.org/project/psycopg2/), which has been superseded by [`psycopg` 3](https://pypi.org/project/psycopg/): https://github.com/typeddjango/django-stubs/blob/2446b523d5caee05dc064805216a07f03e8d828d/django-stubs/contrib/postgres/fields/ranges.pyi#L9 the [`types-psycopg2`](https://pypi.org/project/types-psycopg2/) typeshed stubs package could help with the `# type: ignore`, btw...
# Bug report Wrongly specified inheritance and attributes. ## What's wrong https://github.com/typeddjango/django-stubs/blob/2a89bb5e9ba7da7bbcb6f11dfa56b147d5aef5e2/django-stubs/contrib/auth/middleware.pyi#L30C1-L33C78 vs: https://github.com/django/django/blob/f920937c8a63df6bea220e4386f59cdb45b2e355/django/contrib/auth/middleware.py#L93 ## System information - OS: - `python` version: 3.13 - `django` version: 5.2.1 - `django-stubs` version:...
I am working with a few models where annotations are added in queryset functions. What would be the correct way to type the returned queryset to maintain the ability chain...
# I have made things! ## Related issues None I could find. This change allows for recognizing when `.widget` is used on `Field` instance and when on the type itself,...
``` story_models: QuerySet[StoryModel] = StoryModel.objects.filter( member_id=owner_member_id, created__gte=dtz.now() - timedelta(days=1), is_deleted=False, ).order_by("-created") class StoryModel(TimeStampedModel): member = models.ForeignKey( MemberModel, on_delete=models.CASCADE, related_name="member_story", help_text="스토리 주인 멤버" ) file = ResizedImageField(quality=80, upload_to=get_s3_file_path_for_story) is_show = models.BooleanField(default=True,...
# Bug report ## What's wrong For some reason [`django.db.models.lookups.Lookup` requires a type argument](https://github.com/typeddjango/django-stubs/blob/master/django-stubs/db/models/lookups.pyi#L15) and I do not see anywhere in the file where the `_T` argument is actually used...
We need to address these problems found by https://github.com/typeddjango/django-stubs/blob/ee8e8b11c37866969ff0406be20591a067dfa983/scripts/stubtest/allowlist_todo_django52.txt#L78C1-L80 See https://github.com/django/django/commit/06bf06a911695c5c84f746742f764c040e237ece for `commands` addition.
# Bug report ## What's wrong I have the following models: ```python # Content from video.models class BackingVideo(AudioMixin): asset = models.OneToOneField( "video.Asset", on_delete=models.SET_NULL, null=True, blank=True, related_name="backing_video" ) class Asset(BaseModelMixin): mux_asset_id...
In e.g. `django.db.models.Model.[a]refresh_from_db`, `Self` is used in a contravariant position: https://github.com/typeddjango/django-stubs/blob/0be73ebfbc405d0b9faaa898660b2e51e7d6086a/django-stubs/db/models/base.pyi#L96-L107 When I override this in my own model as e.g. ```py @override def refresh_from_db( self, using: str | None...