From acfe0ce820a5697e9f88ba3e4cb00323dcdc5721 Mon Sep 17 00:00:00 2001 From: Chris Beaven Date: Wed, 16 Jun 2021 19:32:47 +1200 Subject: [PATCH] Patch detail and list generic view base classes (#642) Similar to the already patched `FormMixin`, the detail and list generic view classes are also missing __class_getitem__ and choke when you try to use their generics. --- django_stubs_ext/django_stubs_ext/patch.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/django_stubs_ext/django_stubs_ext/patch.py b/django_stubs_ext/django_stubs_ext/patch.py index c48fb19..8784e9f 100644 --- a/django_stubs_ext/django_stubs_ext/patch.py +++ b/django_stubs_ext/django_stubs_ext/patch.py @@ -7,7 +7,9 @@ from django.contrib.admin.options import BaseModelAdmin from django.db.models.fields import Field from django.db.models.manager import BaseManager from django.db.models.query import QuerySet +from django.views.generic.detail import SingleObjectMixin from django.views.generic.edit import FormMixin +from django.views.generic.list import MultipleObjectMixin _T = TypeVar("_T") _VersionSpec = Tuple[int, int] @@ -38,7 +40,9 @@ class MPGeneric(Generic[_T]): # this list stores them so `monkeypatch` can fix them when called _need_generic: List[MPGeneric[Any]] = [ MPGeneric(ModelAdmin), + MPGeneric(SingleObjectMixin), MPGeneric(FormMixin), + MPGeneric(MultipleObjectMixin), MPGeneric(BaseModelAdmin), MPGeneric(Field), # These types do have native `__class_getitem__` method since django 3.1: