django-types
django-types copied to clipboard
Link to django_stubs_ext is broken
In the README.md file, there is this section:
You can get a
TypeError: 'type' object is not subscriptablewhen you will try to useQuerySet[MyModel],Manager[MyModel]or some other Django-based Generic types.This happens because these Django classes do not support
__class_getitem__magic method in runtime.
You can go with
django_stubs_exthelper, that patches all the types we use as Generic in django.Install it:
pip install django-stubs-ext # as a production dependencyAnd then place in your top-level settings:
import django_stubs_ext django_stubs_ext.monkeypatch()You can add extra types to patch with
django_stubs_ext.monkeypatch(extra_classes=[YourDesiredType])You can use strings instead:
'QuerySet[MyModel]'and'Manager[MyModel]', this way it will work as a type for type-checking and as a regularstrin runtime.
As a newcomer to types in Python, I find this whole section confusing. But the bug I want to report is that the link to django_stubs_ext is broken. The directory django_stubs_ext doesn't seem to exist any more.