{ "info": { "author": "Gustav Wengel", "author_email": "gustavwengel@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "\n\n# Django Auto-Prefetching\n*Never worry about n+1 performance problems again*\n\nThis project aims to automatically perform the correct `select_related` and `prefetch_related`\ncalls for your django-rest-framework code. It does this by inspecting your serializers, seeing what fields\nthey use, and what models they refer to, and automatically calculating what needs to be prefetched.\n\n## Installation\n`pip install django_auto_prefetching`\n\n## AutoPrefetchViewSetMixin\nThis is a ViewSet mixin you can use, which will automatically prefetch the needed objects from the database.\nIn most circumstances this will be all the database optimizations you'll ever need to do:\n\n### Usage\nSimply add it after your ModelViewSet class.\n\n```python\nfrom django_auto_prefetching import AutoPrefetchViewSetMixin\nfrom rest_framework.viewsets import ModelViewSet\n\nclass BaseModelViewSet(AutoPrefetchViewSetMixin, ModelViewSet):\n queryset = YourModel.objects.all()\n serializer_class = YourModelSerializer\n```\nIt supports all types of relational fields, (many to many, one to many, one to one, etc.) out of the box.\n\n### Limitations\nThe `AutoPrefetchViewSetMixin` cannot see what objects are being accessed in e.g. a `SerializerMethodField`.\nIf you use objects in there, you might need to do some additional prefetches.\n\n```python\nfrom django_auto_prefetching import AutoPrefetchViewSetMixin\nfrom rest_framework.viewsets import ModelViewSet\n\nclass BaseModelViewSet(AutoPrefetchViewSetMixin, ModelViewSet):\n serializer_class = YourModelSerializer\n\n def get_queryset(self):\n # Simply do the extra select_related / prefetch_related here\n # and leave the mixin to do the rest of the work\n queryset = YourModel.objects.all()\n queryset = queryset.select_related('my_extra_field')\n return queryset\n\n```\n\n## Supported Versions\nCurrently the project is only being tested against the latest version of Python (3.7) and the latest version of Django(2.2)\nPull Requests to support earlier versions of Django are welcome.\n\n## Maturity\nThe project is currently being used without issues in a medium-sized Django project(20.000 lines of code)\n\n## Contributing\nContributions are welcome! To get the tests running, do the following:\n- Clone the repository.\n- If you don't have it, install [pipenv](https://docs.pipenv.org/en/latest/install/#installing-pipenv)\n- Install the dependencies with `pipenv sync --dev`\n- Activate the virtualenv created by pipenv by writing `pipenv shell`\n- Run the tests with `./manage.py test` \n\n# LICENSE:\nMIT\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/GeeWee/django-auto-prefetching", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-auto-prefetching", "package_url": "https://pypi.org/project/django-auto-prefetching/", "platform": "", "project_url": "https://pypi.org/project/django-auto-prefetching/", "project_urls": { "Homepage": "https://github.com/GeeWee/django-auto-prefetching" }, "release_url": "https://pypi.org/project/django-auto-prefetching/0.1.7/", "requires_dist": [ "django (~=2.2)", "djangorestframework (~=3.9) ; extra == 'rest_framework_integration'" ], "requires_python": ">=3.7.0", "summary": "Tools for automatically prefetching related objects in Django and Django-rest-framework", "version": "0.1.7" }, "last_serial": 5690925, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "e7fddb1047f50987f1a4834a45ea09a0", "sha256": "f391e74a7088ef643704f6fbce46ba7a4a17514ddd5437de00e390d33e78230c" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e7fddb1047f50987f1a4834a45ea09a0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.7.0", "size": 18666, "upload_time": "2019-05-04T12:13:35", "url": "https://files.pythonhosted.org/packages/c9/9a/269d9cba851e4610a735110497e0e1d9bbed7a2d1d171ce31c41c3fd004b/django_auto_prefetching-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "39d2669416e876c32981ad69b7c0c606", "sha256": "1f571b64dd67a8c945c656059c13d5d5a95103a07d1cad7f4ccefe916e4036ac" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.1.tar.gz", "has_sig": false, "md5_digest": "39d2669416e876c32981ad69b7c0c606", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7.0", "size": 10584, "upload_time": "2019-05-04T12:13:37", "url": "https://files.pythonhosted.org/packages/5b/43/4b35339aa2f342f091bfaacd91a624f0762c6d6e89258c8cd21c95534804/django_auto_prefetching-0.1.1.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "11c9868a860803c309f6e23408638d5c", "sha256": "a3794ffe588df4bbe8017640fa89f6ae0c0378e7631eef64f16562623ab39cbd" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "11c9868a860803c309f6e23408638d5c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.7.0", "size": 18510, "upload_time": "2019-05-21T06:21:26", "url": "https://files.pythonhosted.org/packages/e1/ad/9e51a2035a578a1786108e0436b67ce4b31b75a1cede1f7b5319aa80b187/django_auto_prefetching-0.1.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d3b1fb4e6a6cdd4f0e08b069a04f195e", "sha256": "7bc0ac5994a4fd83948d2af54c106cb9bd07499413d02f998e39f6253759e67d" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.3.tar.gz", "has_sig": false, "md5_digest": "d3b1fb4e6a6cdd4f0e08b069a04f195e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7.0", "size": 10534, "upload_time": "2019-05-21T06:21:27", "url": "https://files.pythonhosted.org/packages/60/ee/800765d19a865b4413ced2fb91d5b6732064c2a31adda03925bd2ac8d5db/django_auto_prefetching-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "688990df11a5466d4c09689a480270aa", "sha256": "9686a9acccce59fc1ce00a2ce70b239f09a9c46479d5d9d47c10cdfbae7719bf" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "688990df11a5466d4c09689a480270aa", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.7.0", "size": 18510, "upload_time": "2019-05-21T06:21:49", "url": "https://files.pythonhosted.org/packages/87/0d/d5512e540d553cbf9965c38d6850a67a2761b257e51cb3dc3b89071bf954/django_auto_prefetching-0.1.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "62ff506aa067e543452d082cbdb57e80", "sha256": "a20a9b2e9faf6cb4dd60c9c076a687fc67fdde56dead060428880879773a103d" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.4.tar.gz", "has_sig": false, "md5_digest": "62ff506aa067e543452d082cbdb57e80", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7.0", "size": 10540, "upload_time": "2019-05-21T06:21:51", "url": "https://files.pythonhosted.org/packages/3a/92/01448528148d4d0fa7c3c922ac25aca80be57fd3a6ff477e319ec0befc97/django_auto_prefetching-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "7c8822ef2b8e951cfe2431749d799394", "sha256": "e85626332b8ddfa92e050257e7219c3ea637d1a68b6708815e307e2f71dcbd1d" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7c8822ef2b8e951cfe2431749d799394", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.7.0", "size": 18673, "upload_time": "2019-05-21T18:12:40", "url": "https://files.pythonhosted.org/packages/ca/f6/c139ec0ff8a799ac507c6af302e1ee86b14627cfb41d83580819d379feac/django_auto_prefetching-0.1.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "30ebef4229713ad6ecbd2a03b42efcaa", "sha256": "f56794e5e378bcb68391457110a0b31bf8137273c41f6c59f8841a0115135a56" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.5.tar.gz", "has_sig": false, "md5_digest": "30ebef4229713ad6ecbd2a03b42efcaa", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7.0", "size": 10694, "upload_time": "2019-05-21T18:12:41", "url": "https://files.pythonhosted.org/packages/75/1a/70f3f614c2c671c1a1d2e0ec4a85a43f26f7916eb2c110565dff0f8ba9af/django_auto_prefetching-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "ffd329ef4f5dada8016c0bf0c6eae9ef", "sha256": "d1d89f50bc6dab377b60d8b378257953aa8ca015cb1be0c5e9e32b9e18f31b14" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ffd329ef4f5dada8016c0bf0c6eae9ef", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.7.0", "size": 19237, "upload_time": "2019-05-28T05:32:42", "url": "https://files.pythonhosted.org/packages/6c/9e/792a73b05adaafdfabf1bf4cfbe4b53650ab8f7c2c97c82229e1726df64d/django_auto_prefetching-0.1.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "84e725392cfdee36d1aaa38b93b6799c", "sha256": "7d3c9b977f3f0840054cca470c4952a1b667a29fc62065a65b601a7b4b36685a" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.6.tar.gz", "has_sig": false, "md5_digest": "84e725392cfdee36d1aaa38b93b6799c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7.0", "size": 11364, "upload_time": "2019-05-28T05:32:44", "url": "https://files.pythonhosted.org/packages/4c/d9/ba81e73f4949cf5b7e09afe8fe15d1cc4494cf42b993b878bd7c3855e0c0/django_auto_prefetching-0.1.6.tar.gz" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "26bcd20f7db36111ef2ed0ce033c41e5", "sha256": "bb31c772c309b5334d4db2e6268aa83176d6973469bf0e1f25a29473e07e6a87" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "26bcd20f7db36111ef2ed0ce033c41e5", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.7.0", "size": 22154, "upload_time": "2019-08-17T08:06:13", "url": "https://files.pythonhosted.org/packages/81/c8/e4a7fd25b6d838a56052d502318b33b9adef9ca24f64bb43b6750afe2571/django_auto_prefetching-0.1.7-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3600c6bfbc6c2cbb7eed597d8da96faf", "sha256": "c0abeaa70555f1cc18a44cf5da0a39b4dc0bad81926ec4c3b5bcce9d3ceb762e" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.7.tar.gz", "has_sig": false, "md5_digest": "3600c6bfbc6c2cbb7eed597d8da96faf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7.0", "size": 9375, "upload_time": "2019-08-17T08:06:16", "url": "https://files.pythonhosted.org/packages/6c/b6/d7f65e9ce8f00baea4e366fd27742310e2d118e47bb2516ce2aedb8dfdad/django_auto_prefetching-0.1.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "26bcd20f7db36111ef2ed0ce033c41e5", "sha256": "bb31c772c309b5334d4db2e6268aa83176d6973469bf0e1f25a29473e07e6a87" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "26bcd20f7db36111ef2ed0ce033c41e5", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.7.0", "size": 22154, "upload_time": "2019-08-17T08:06:13", "url": "https://files.pythonhosted.org/packages/81/c8/e4a7fd25b6d838a56052d502318b33b9adef9ca24f64bb43b6750afe2571/django_auto_prefetching-0.1.7-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3600c6bfbc6c2cbb7eed597d8da96faf", "sha256": "c0abeaa70555f1cc18a44cf5da0a39b4dc0bad81926ec4c3b5bcce9d3ceb762e" }, "downloads": -1, "filename": "django_auto_prefetching-0.1.7.tar.gz", "has_sig": false, "md5_digest": "3600c6bfbc6c2cbb7eed597d8da96faf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7.0", "size": 9375, "upload_time": "2019-08-17T08:06:16", "url": "https://files.pythonhosted.org/packages/6c/b6/d7f65e9ce8f00baea4e366fd27742310e2d118e47bb2516ce2aedb8dfdad/django_auto_prefetching-0.1.7.tar.gz" } ] }