mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-16 08:47:49 +08:00
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.
This commit is contained in:
@@ -7,7 +7,9 @@ from django.contrib.admin.options import BaseModelAdmin
|
|||||||
from django.db.models.fields import Field
|
from django.db.models.fields import Field
|
||||||
from django.db.models.manager import BaseManager
|
from django.db.models.manager import BaseManager
|
||||||
from django.db.models.query import QuerySet
|
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.edit import FormMixin
|
||||||
|
from django.views.generic.list import MultipleObjectMixin
|
||||||
|
|
||||||
_T = TypeVar("_T")
|
_T = TypeVar("_T")
|
||||||
_VersionSpec = Tuple[int, int]
|
_VersionSpec = Tuple[int, int]
|
||||||
@@ -38,7 +40,9 @@ class MPGeneric(Generic[_T]):
|
|||||||
# this list stores them so `monkeypatch` can fix them when called
|
# this list stores them so `monkeypatch` can fix them when called
|
||||||
_need_generic: List[MPGeneric[Any]] = [
|
_need_generic: List[MPGeneric[Any]] = [
|
||||||
MPGeneric(ModelAdmin),
|
MPGeneric(ModelAdmin),
|
||||||
|
MPGeneric(SingleObjectMixin),
|
||||||
MPGeneric(FormMixin),
|
MPGeneric(FormMixin),
|
||||||
|
MPGeneric(MultipleObjectMixin),
|
||||||
MPGeneric(BaseModelAdmin),
|
MPGeneric(BaseModelAdmin),
|
||||||
MPGeneric(Field),
|
MPGeneric(Field),
|
||||||
# These types do have native `__class_getitem__` method since django 3.1:
|
# These types do have native `__class_getitem__` method since django 3.1:
|
||||||
|
|||||||
Reference in New Issue
Block a user