django-stubs-ext is a Python library that provides essential monkey-patching and extensions for `django-stubs`, significantly enhancing static type checking for Django projects using Mypy. It ensures better compatibility and stub coverage for advanced Django features and commonly used patterns. The library is actively maintained with frequent updates, often aligning with new Django and Mypy releases, and is currently at version 6.0.2.
pip install django-stubs-extVerified import paths — ran on the pinned version, not inferred.
To enable `django-stubs-ext`, add its plugin entry to your `mypy.ini` (or equivalent Mypy configuration file) under the `[mypy]` section. This activates the extensions and monkey-patches provided by the library.
Upgrade your Django project to a compatible version (Django 6.0 or newer). Consider pinning `django-stubs-ext` to `~=5.2` if you are on an older Django version.
Ensure your Mypy installation is updated to version 1.20 or newer (`pip install --upgrade mypy`).
Upgrade to `django-stubs-ext` version 6.0.1 or newer (`pip install --upgrade django-stubs-ext`).
Install `django-stubs` (`pip install django-stubs`) and correctly configure `mypy.ini` as described in the quickstart.
Ensure you are invoking Mypy correctly via the `mypy` command, and not attempting to execute `mypy.ini` or similar configuration files as Python scripts. Refer to the Mypy and `django-stubs` quickstart guides for correct setup instructions.