| Name | djangorestframework-stubs JSON |
| Version |
3.16.5
JSON |
| download |
| home_page | None |
| Summary | PEP-484 stubs for django-rest-framework |
| upload_time | 2025-10-21 19:43:09 |
| maintainer | Marti Raudsepp, Nikita Sobolev |
| docs_url | None |
| author | Maksim Kurnikov |
| requires_python | >=3.10 |
| license | None |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
<img src="https://mypy-lang.org/static/mypy_light.svg" alt="mypy logo" width="300px"/>
# pep484 stubs for Django REST framework
[](https://github.com/typeddjango/djangorestframework-stubs/actions/workflows/test.yml)
[](https://mypy-lang.org/)
[](https://gitter.im/mypy-django/Lobby)
[](https://stackoverflow.com/questions/tagged/django-stubs?tab=Active)
Mypy stubs for [Django REST Framework](https://pypi.org/project/djangorestframework/).
Supports Python 3.10 and up.
## Installation
```bash
pip install djangorestframework-stubs[compatible-mypy]
```
To make mypy aware of the plugin, you need to add
```ini
[mypy]
plugins =
mypy_drf_plugin.main
```
in your `mypy.ini` file.
## FAQ
### Model instance is inferred as `Any` instead of my `Model` class
When subclassing `ModelSerializer`, add a [type argument](https://peps.python.org/pep-0484/#generics) to type-hint the related model class, for example:
```python
class MyModelSerializer(serializers.ModelSerializer[MyModel]):
class Meta:
model = MyModel
fields = ("id", "example")
```
Which means that methods where the model is being passed around will know the actual type of the model instead of being `Any`. The `instance` attribute on the above serializer will be `MyModel | typing.Sequence[MyModel] | None`.
## To get help
We have Gitter here: <https://gitter.im/mypy-django/Lobby>
If you think you have more generic typing issue, please refer to <https://github.com/python/mypy> and their Gitter.
## Contributing
This project is open source and community driven. As such we encourage contributions big and small. You can contribute by doing any of the following:
1. Contribute code (e.g. improve stubs, add plugin capabilities, write tests etc) - to do so please follow the [contribution guide](./CONTRIBUTING.md).
2. Assist in code reviews and discussions in issues.
3. Identify bugs and issues and report these
You can always also reach out in gitter to discuss your contributions!
Raw data
{
"_id": null,
"home_page": null,
"name": "djangorestframework-stubs",
"maintainer": "Marti Raudsepp, Nikita Sobolev",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Marti Raudsepp <marti@juffo.org>, Nikita Sobolev <mail@sobolevn.me>",
"keywords": null,
"author": "Maksim Kurnikov",
"author_email": "Maksim Kurnikov <maxim.kurnikov@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/4a/81/10d0139796e3df5c48e9383ef73e3a999351415e94cc427a4546f79bad07/djangorestframework_stubs-3.16.5.tar.gz",
"platform": null,
"description": "<img src=\"https://mypy-lang.org/static/mypy_light.svg\" alt=\"mypy logo\" width=\"300px\"/>\n\n# pep484 stubs for Django REST framework\n\n[](https://github.com/typeddjango/djangorestframework-stubs/actions/workflows/test.yml)\n[](https://mypy-lang.org/)\n[](https://gitter.im/mypy-django/Lobby)\n[](https://stackoverflow.com/questions/tagged/django-stubs?tab=Active)\n\n\nMypy stubs for [Django REST Framework](https://pypi.org/project/djangorestframework/).\nSupports Python 3.10 and up.\n\n## Installation\n\n```bash\npip install djangorestframework-stubs[compatible-mypy]\n```\n\nTo make mypy aware of the plugin, you need to add\n\n```ini\n[mypy]\nplugins =\n mypy_drf_plugin.main\n```\n\nin your `mypy.ini` file.\n\n## FAQ\n\n### Model instance is inferred as `Any` instead of my `Model` class\n\nWhen subclassing `ModelSerializer`, add a [type argument](https://peps.python.org/pep-0484/#generics) to type-hint the related model class, for example:\n\n```python\nclass MyModelSerializer(serializers.ModelSerializer[MyModel]):\n class Meta:\n model = MyModel\n fields = (\"id\", \"example\")\n```\n\nWhich means that methods where the model is being passed around will know the actual type of the model instead of being `Any`. The `instance` attribute on the above serializer will be `MyModel | typing.Sequence[MyModel] | None`.\n\n## To get help\n\nWe have Gitter here: <https://gitter.im/mypy-django/Lobby>\nIf you think you have more generic typing issue, please refer to <https://github.com/python/mypy> and their Gitter.\n\n## Contributing\n\nThis project is open source and community driven. As such we encourage contributions big and small. You can contribute by doing any of the following:\n\n1. Contribute code (e.g. improve stubs, add plugin capabilities, write tests etc) - to do so please follow the [contribution guide](./CONTRIBUTING.md).\n2. Assist in code reviews and discussions in issues.\n3. Identify bugs and issues and report these\n\nYou can always also reach out in gitter to discuss your contributions!\n",
"bugtrack_url": null,
"license": null,
"summary": "PEP-484 stubs for django-rest-framework",
"version": "3.16.5",
"project_urls": {
"Funding": "https://github.com/sponsors/typeddjango",
"Homepage": "https://github.com/typeddjango/djangorestframework-stubs",
"Release notes": "https://github.com/typeddjango/djangorestframework-stubs/releases"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "93339c8d203d9e409736665e9f4ed2b9986dfb77774c7d17dab392ed498cb201",
"md5": "c448e40b820f167f5ded1812191fe223",
"sha256": "aebd45bc2cf5e52b90651c548ad25c66d5d8d2b11c48147cbaba87498eefd211"
},
"downloads": -1,
"filename": "djangorestframework_stubs-3.16.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c448e40b820f167f5ded1812191fe223",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 56506,
"upload_time": "2025-10-21T19:43:08",
"upload_time_iso_8601": "2025-10-21T19:43:08.065291Z",
"url": "https://files.pythonhosted.org/packages/93/33/9c8d203d9e409736665e9f4ed2b9986dfb77774c7d17dab392ed498cb201/djangorestframework_stubs-3.16.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4a8110d0139796e3df5c48e9383ef73e3a999351415e94cc427a4546f79bad07",
"md5": "f65ac37905158a538239730d045a9e48",
"sha256": "1de13fad78b7de3f7ee34dcc1864929adc658342508567263eaff96a4b32312e"
},
"downloads": -1,
"filename": "djangorestframework_stubs-3.16.5.tar.gz",
"has_sig": false,
"md5_digest": "f65ac37905158a538239730d045a9e48",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 32238,
"upload_time": "2025-10-21T19:43:09",
"upload_time_iso_8601": "2025-10-21T19:43:09.230064Z",
"url": "https://files.pythonhosted.org/packages/4a/81/10d0139796e3df5c48e9383ef73e3a999351415e94cc427a4546f79bad07/djangorestframework_stubs-3.16.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-21 19:43:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sponsors",
"github_project": "typeddjango",
"github_not_found": true,
"lcname": "djangorestframework-stubs"
}