{ "info": { "author": "Jordan Rolson", "author_email": "jdroloson@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.8", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "=====\nPrefetch Plus\n=====\n\nPrefetch Plus aims to add additional flexibility to django's built in\nprefetch_related functionality. \n\nUsing the built in prefetch_related you can only select objects related through\nreverse ForeignKey relationships. With PrefetchPlus you can slect objects related\nthrough any mapping of columns from one table to another.\n\nThis allows forsomething much more similar to the capabilities of a\ndatabases left outer join.\n\nInstallation\n-----------\npip install django-prefetch-plus\n\nUsage\n-----------\n\nAs Manager:\n\nPrefetch Plus comes with the PrefetchPlusQuerySet which provides a similar\ninterface to prefetch_related:\n```\nfrom prefetch_plus import PrefetchPlusQuerySet\nfrom django.db import models\n\nGENRES = (\n ...\n ('romance', 'Romance'),\n ('mystery', 'Mystery'),\n)\n\n\nclass Author(models.Model)\n ...\n genre = models.CharField(\n choices = GENRES\n )\n ...\n objects = PrefetchPlusQuerySet.as_manager()\n\nclass Book(models.Model)\n ...\n author = models.ForeignKey(\n Author\n )\n\n genre = models.CharField(\n choices = GENRES\n )\n ...\n\n# We want to have author's of books review other books in the same genre.\n\n# The old way\nfor author in Author.objects.all():\n # Typical N+1 db query that cannot be resolved with builtin prefetch_related\n author.books_to_review = list(Book.objects.filter(genre=author.genre))\n\n# The new way\n# This will grab all of the Books that share a genre with any author,\n# then it will attach attach the list of books in each genre to the matching\n# author(s)\nauthors = Author.objects.prefetch_plus(\n to_attr='books_to_review',\n query_set=Book.objects.all(),\n obj_cols='genre',\n qset_cols='genre'\n).all()\n# obj_cols & qset_cols can also be tuples of columns to allow for\n# \"composite keys\". The tuple must be the same length and the matches are\n# getattr(object, obj_cols[i]) == getattr(qset_object, qset_cols[i]) for any i\n\n# Prefetch plus works across related objects. I highly recommend you remember to\n# select_related if you do this. Otherwise, you aren't getting any benefit out\n# of this\nauthors = Author.objects.prefetch_plus(\n to_attr='books_to_review',\n query_set=Book.objects.select_related('author').all(),\n obj_cols='genre',\n qset_cols='author__genre'\n).all()\n```\n\nWithout the manager:\n\nYou don't have to use the manager if you don't want, it simply calls the\nfollowing helper function at the appropriate time\n\n```\nfrom prefetch_plus import do_prefetch_plus\nfrom django.db import models\n\nGENRES = (\n ...\n ('romance', 'Romance'),\n ('mystery', 'Mystery'),\n)\n\n\nclass Author(models.Model)\n ...\n genre = models.CharField(\n choices = GENRES\n )\n ...\n\nclass Book(models.Model)\n ...\n author = models.ForeignKey(\n Author\n )\n\n genre = models.CharField(\n choices = GENRES\n )\n ...\n\n# We want to have author's of books review other books in the same genre.\n\nauthors = Author.objects.all()\n\ndo_prefetch_plus(\n objects=authors,\n to_attr='books_to_review',\n query_set=Book.objects.all(),\n obj_cols='genre',\n qset_cols='genre'\n)\n```\n\nVersion History\n-----------\n0.3.3: Made Prefetch plus faster at the cost of potentially grabbing extra\n records in the case of composite keys. Fixed support for 2.7", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jdroloson/django-prefetch-plus", "keywords": "", "license": "BSD License", "maintainer": "", "maintainer_email": "", "name": "django-prefetch-plus", "package_url": "https://pypi.org/project/django-prefetch-plus/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-prefetch-plus/", "project_urls": { "Homepage": "https://github.com/jdroloson/django-prefetch-plus" }, "release_url": "https://pypi.org/project/django-prefetch-plus/0.3.3/", "requires_dist": null, "requires_python": "", "summary": "More generic form of django prefetch_related", "version": "0.3.3" }, "last_serial": 2313820, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "9d26e95496890162d252637916e2c795", "sha256": "dd062eb43ee40bc131e71ec51e0f0f7007eeba012ac3a684f805327147a68014" }, "downloads": -1, "filename": "django-prefetch-plus-0.1.tar.gz", "has_sig": false, "md5_digest": "9d26e95496890162d252637916e2c795", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4566, "upload_time": "2016-03-07T02:31:04", "url": "https://files.pythonhosted.org/packages/4c/a4/71faa4f21a1feca718101520e76f9e67084dcdf1ab832ef86b3c89286a5d/django-prefetch-plus-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "9864de95d1c134026b5577ea87169497", "sha256": "f5156034f0c6df238973f29cd869dd0dd76454369ca99a997875e6f910cde04d" }, "downloads": -1, "filename": "django_prefetch_plus-0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9864de95d1c134026b5577ea87169497", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5974, "upload_time": "2016-08-30T15:38:20", "url": "https://files.pythonhosted.org/packages/91/9c/38f9324b8e3d59270a690d4f073fd72ca8d4403172236db1c52be0da552c/django_prefetch_plus-0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "dd92ce28e4853905cd0979744f4f8313", "sha256": "8a7af3b76bdac62ba49fe8c145c9196151f0e83322eca35b364928a2ca3d0bfb" }, "downloads": -1, "filename": "django-prefetch-plus-0.2.tar.gz", "has_sig": false, "md5_digest": "dd92ce28e4853905cd0979744f4f8313", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4696, "upload_time": "2016-08-30T15:38:22", "url": "https://files.pythonhosted.org/packages/0f/e5/e276a6ae00154bddc4e96fdbd4ec3ec20be04d1cff465c8a2a1228534fa0/django-prefetch-plus-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "b1c6273d668a00e44d921d85308c94e7", "sha256": "5dd5eb0f3a693f3200541371ac3cff44ee96aab5f8a348d0c44218290d3a0115" }, "downloads": -1, "filename": "django_prefetch_plus-0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b1c6273d668a00e44d921d85308c94e7", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5926, "upload_time": "2016-08-30T15:45:12", "url": "https://files.pythonhosted.org/packages/ee/4b/7234fcfed02595f200c223bd8c0db2f8f8278196988998b04d0523d7fac9/django_prefetch_plus-0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e62f5f07753a7b17414b2368a0b1b614", "sha256": "e60022c24d1df7a52d1054bcbda02f106a77e831aff60d66c3d45c71289eef38" }, "downloads": -1, "filename": "django-prefetch-plus-0.3.tar.gz", "has_sig": false, "md5_digest": "e62f5f07753a7b17414b2368a0b1b614", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4671, "upload_time": "2016-08-30T15:45:14", "url": "https://files.pythonhosted.org/packages/0c/71/0ac9a60f7d838c5c1c9e9960d147d048009180d272e95305392f07a862c0/django-prefetch-plus-0.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "39601d40f5fe75099149b15e8fd16bc1", "sha256": "566bda5db09fe82ad56095826663b62d7a7abb6874c3095825f70672b90d8fa5" }, "downloads": -1, "filename": "django_prefetch_plus-0.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "39601d40f5fe75099149b15e8fd16bc1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5986, "upload_time": "2016-08-30T16:04:09", "url": "https://files.pythonhosted.org/packages/06/9a/ff54012b17222d3f77ee7d161e8372d34a067646050ccea41e71f2f201b0/django_prefetch_plus-0.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2b3834037d09bbdaeb4912fb30f9d066", "sha256": "54f96d825cdda1adc16159f8021c5a5c76d57fb200c776a898bbc8031dde54f9" }, "downloads": -1, "filename": "django-prefetch-plus-0.3.1.tar.gz", "has_sig": false, "md5_digest": "2b3834037d09bbdaeb4912fb30f9d066", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4687, "upload_time": "2016-08-30T16:04:11", "url": "https://files.pythonhosted.org/packages/f1/c8/b8e35c865b9ccfd5d18b8889ff6e93543ca8691419e9723bd4adfa3e903f/django-prefetch-plus-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "7a81418de06edcd73dc3e4e20fc8a851", "sha256": "2c19caa18920e2db9f959215a5df210c705b7d1cca284b11f66e2867b0072dcc" }, "downloads": -1, "filename": "django_prefetch_plus-0.3.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7a81418de06edcd73dc3e4e20fc8a851", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6039, "upload_time": "2016-08-30T16:20:15", "url": "https://files.pythonhosted.org/packages/3a/9a/598faac2d661f2b67bab4b335ce56f1fc5587c5bc9b183ce215731c377da/django_prefetch_plus-0.3.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "542b11f09d87b031bb2378c683ac1a40", "sha256": "a77d782f4a219babfa5200a197b81b44c1ef221de85c2d46cffe520e935fec01" }, "downloads": -1, "filename": "django-prefetch-plus-0.3.2.tar.gz", "has_sig": false, "md5_digest": "542b11f09d87b031bb2378c683ac1a40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4742, "upload_time": "2016-08-30T16:20:17", "url": "https://files.pythonhosted.org/packages/99/87/a434ed68c62bc4016b15e706f86cf7e4350db72b9d503d62c9629e65c1cb/django-prefetch-plus-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "bc4f262aee9a0adddf732f3480e6e05f", "sha256": "7467dd1c56ec1ddc083ace0b7a77bc8f69739a4ca875338a4bd9509e42bf48b5" }, "downloads": -1, "filename": "django_prefetch_plus-0.3.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bc4f262aee9a0adddf732f3480e6e05f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6043, "upload_time": "2016-08-30T16:26:46", "url": "https://files.pythonhosted.org/packages/7d/a2/2540780f1b138c4d8be99c20353c8fa2a344cb7cc249633cd6a89985978f/django_prefetch_plus-0.3.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8fac9a5059e5c905d2c66c6c36410a98", "sha256": "8d1367ad1a5db7b9b7fdd538509e65abd8c233bda8fd3ca04c569e2cf4ceac31" }, "downloads": -1, "filename": "django-prefetch-plus-0.3.3.tar.gz", "has_sig": false, "md5_digest": "8fac9a5059e5c905d2c66c6c36410a98", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4725, "upload_time": "2016-08-30T16:26:48", "url": "https://files.pythonhosted.org/packages/c7/3b/435d53f1b6be53b3c4dc07e7e8d9f36cedf68610093b7be66260f18e87a0/django-prefetch-plus-0.3.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bc4f262aee9a0adddf732f3480e6e05f", "sha256": "7467dd1c56ec1ddc083ace0b7a77bc8f69739a4ca875338a4bd9509e42bf48b5" }, "downloads": -1, "filename": "django_prefetch_plus-0.3.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bc4f262aee9a0adddf732f3480e6e05f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6043, "upload_time": "2016-08-30T16:26:46", "url": "https://files.pythonhosted.org/packages/7d/a2/2540780f1b138c4d8be99c20353c8fa2a344cb7cc249633cd6a89985978f/django_prefetch_plus-0.3.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8fac9a5059e5c905d2c66c6c36410a98", "sha256": "8d1367ad1a5db7b9b7fdd538509e65abd8c233bda8fd3ca04c569e2cf4ceac31" }, "downloads": -1, "filename": "django-prefetch-plus-0.3.3.tar.gz", "has_sig": false, "md5_digest": "8fac9a5059e5c905d2c66c6c36410a98", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4725, "upload_time": "2016-08-30T16:26:48", "url": "https://files.pythonhosted.org/packages/c7/3b/435d53f1b6be53b3c4dc07e7e8d9f36cedf68610093b7be66260f18e87a0/django-prefetch-plus-0.3.3.tar.gz" } ] }