{ "info": { "author": "Chris Seto", "author_email": "chriskseto@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.10", "Framework :: Django :: 1.11", "Framework :: Django :: 1.9", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "**************\nDjango Include\n**************\n\n.. image:: https://badge.fury.io/py/django-include.svg\n :target: http://badge.fury.io/py/django-include\n :alt: Latest version\n\n.. image:: https://travis-ci.org/chrisseto/django-include.svg?branch=master\n :target: https://travis-ci.org/chrisseto/django-include\n\nORM extensions for performance-conscious perfectionists.\n\nDjango-include provides ``select_related`` functionality for Many-to-X relations.\n\n\nRequirements\n============\n\nPython 2.7 or 3.5+, Django 1.9+, and any SQL server with support for JSON aggregations.\n\nCurrently tested against Postgres 9.6. May work with SQLite with the JSON1 extension.\n\n\nInstallation\n============\n\n::\n\n pip install django-include\n\nUsage\n=====\n\nAdd `include` to `INSTALLED_APPS`.\n\nAttach ``IncludeManager`` to a model:\n\n.. code-block:: python\n\n from include import IncludeManager\n\n class BlogPost(models.Model):\n objects = IncludeManager()\n\nSubclass `IncludeQuerySet`:\n\n.. code-block:: python\n\n from include import IncludeQuerySet\n\n class CustomQuerySet(IncludeQuerySet):\n def custom_method(self):\n pass\n\n class BlogPost(models.Model):\n objects = CustomQuerySet.as_manager()\n\n\nWhat/Why?\n=========\n\nConsider the following:\n\nGiven the following models.\n\n.. code-block:: python\n\n class Email(Model):\n name = CharField()\n user = ForeignKey('User')\n\n\n class User(Model):\n emails = ...\n\n\n class Contributor(Model):\n role = CharField()\n user = ForeignKey('User')\n project = ForeignKey('Project')\n\n class Project(Model):\n contributors = ...\n\nThere is an endpoint that returns all the users that contributed to a project, their roles, and their email addresses.\n\nIf this endpoint were to be implemented using just Django's ORM, it would end up looking something like this:\n\n.. code-block:: python\n\n project = Project.objects.get(pk=id) # 1 Query\n for contributor in project.contributors.select_related('users'): # 1 Query\n [x for x in contributor.user.emails.all()] # N * M Queries!\n # Some serialization code\n\nAt first this solution seems fine, but what happens when a project has an entire college of people, each with a couple email addresses?\nNow, there are certainly other tricks that could be done here to reduce the number of queries and runtime.\nFor instance, dropping down into raw SQL with a couple joins and/or subselects.\n\nOr you could just use `.include`, do a single query, and not have to explain all the *neat* things you did.\n\n.. code-block:: python\n\n project = Project.objects.include('contributors__user__emails') # 1 Query\n for contributor in project.contributors.all(): # Already loaded\n [x for x in contributor.user.emails.all()] # Already loaded\n # Some serialization code\n\nHow?\n====\n\nDjango Include abuses JSON aggregations and Django's `extra`/`annotate` functions to embed related data.\n\nLicense\n=======\n\nMIT licensed. See the bundled `LICENSE `_ file for more details.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/chrisseto/django-include", "keywords": "django,postgres,sql,optimization,performance", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-include", "package_url": "https://pypi.org/project/django-include/", "platform": "", "project_url": "https://pypi.org/project/django-include/", "project_urls": { "Homepage": "http://github.com/chrisseto/django-include" }, "release_url": "https://pypi.org/project/django-include/0.2.4/", "requires_dist": [ "psycopg2", "ciso8601; extra == 'faster'", "ujson; extra == 'faster'" ], "requires_python": "", "summary": "ORM extensions for performance-conscious perfectionists.", "version": "0.2.4" }, "last_serial": 3168647, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "07b54489a696c68fe3f3d54374b6c685", "sha256": "849d517270c85b0a0521abdfb9294409e868226f21a5a0cc0b5352560d1e7463" }, "downloads": -1, "filename": "django_include-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "07b54489a696c68fe3f3d54374b6c685", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9285, "upload_time": "2017-04-17T15:19:31", "url": "https://files.pythonhosted.org/packages/a5/0e/9d6273a7de3c3a8c3aa064d597c36cbddafb8dc0b867b0d1556e0957d262/django_include-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "12cf3476de52d5a0ab97941a0e4f5a09", "sha256": "bc3bd75d8ac3e9be2caebe64323aab90397746469626cee7771c15823a3954d5" }, "downloads": -1, "filename": "django-include-0.1.0.tar.gz", "has_sig": false, "md5_digest": "12cf3476de52d5a0ab97941a0e4f5a09", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9915, "upload_time": "2017-04-17T15:19:33", "url": "https://files.pythonhosted.org/packages/dc/b7/87d61ffc297fa93ed6c91cdf0ee4dcf400263db758225099d98656cfcc16/django-include-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "40aed4c2528b988d68008df512d30f22", "sha256": "b288d6b7534df6acbe1806b0ac5548662392570ddab0381b58b7b60db5a02d97" }, "downloads": -1, "filename": "django_include-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "40aed4c2528b988d68008df512d30f22", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10566, "upload_time": "2017-07-13T15:34:08", "url": "https://files.pythonhosted.org/packages/fd/36/2ee7225fc4688a7e665195de12c8fd974cefcfc785d917e046df0a7b063f/django_include-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "da986171b65dcbb5a5fc9d60f422b2fd", "sha256": "6a291999c8168a983f4d2c787b04e8763ee254733cc8f278aa43fd7d08cfe551" }, "downloads": -1, "filename": "django-include-0.2.0.tar.gz", "has_sig": false, "md5_digest": "da986171b65dcbb5a5fc9d60f422b2fd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12775, "upload_time": "2017-07-13T15:34:12", "url": "https://files.pythonhosted.org/packages/fb/32/2121c6293126c5f9164494c2661dc6d63114f152677c42575ad3c3fd04f0/django-include-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "f91f6e3c7ca1c8d2db28653958601040", "sha256": "73980774a1c251319e7e6bf7dcb6578dd1721578fa3c90d805499dd9733b6a76" }, "downloads": -1, "filename": "django_include-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f91f6e3c7ca1c8d2db28653958601040", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10575, "upload_time": "2017-07-13T17:33:18", "url": "https://files.pythonhosted.org/packages/1d/ff/7da397012ff5d1bb9e50f9a98d083664bf88969a500411dc039b0a39bd84/django_include-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "912613b7d09b4da1495486625c5333c9", "sha256": "3932add0deaae678f8f3af09d1aead95ae6c63b5e5d9cab2e3efcc4bf94e40af" }, "downloads": -1, "filename": "django-include-0.2.1.tar.gz", "has_sig": false, "md5_digest": "912613b7d09b4da1495486625c5333c9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13164, "upload_time": "2017-07-13T17:33:19", "url": "https://files.pythonhosted.org/packages/33/95/0b968ee92ab3ff3614e5f6d503ac408a3b88501eb437b56641ec50c8e692/django-include-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "7474648bbf17ff3797eba8d311540d71", "sha256": "5138554f18a24d5d67905e93c1be6b2f101b937271530e51b283452fb0d7a626" }, "downloads": -1, "filename": "django_include-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7474648bbf17ff3797eba8d311540d71", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10733, "upload_time": "2017-08-29T13:45:45", "url": "https://files.pythonhosted.org/packages/e9/b2/5882bf7fd466843d5ac00b0cb79a12cd39d86bdbeccbcecfe66090e6f6e2/django_include-0.2.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "664d0afd9b57c489076d021c362a9c63", "sha256": "4eecd3d81b130cc6ada69fc25c11b287c75dac9790b050f495c9a7ec61999940" }, "downloads": -1, "filename": "django-include-0.2.2.tar.gz", "has_sig": false, "md5_digest": "664d0afd9b57c489076d021c362a9c63", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13729, "upload_time": "2017-08-29T13:45:45", "url": "https://files.pythonhosted.org/packages/f9/31/b7b4422f85a86b16e323c0b83aa1899d79d82ad0c1349c0447236d3d5a85/django-include-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "ea46f8086efe58e22603516fc6922e4c", "sha256": "3c7d81870d68775a4977b4596f495a14cd97a1dd699cb15fdcb81a3715c35a88" }, "downloads": -1, "filename": "django_include-0.2.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ea46f8086efe58e22603516fc6922e4c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10703, "upload_time": "2017-09-08T13:19:40", "url": "https://files.pythonhosted.org/packages/3f/94/34ec0a44eebcdc36823a40a2949bf2ab132531690a5826771356c736aaea/django_include-0.2.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "272dea71bb1a0f54d508c08e96b69a51", "sha256": "96d386c30e514367b5de2df8bf26ac70fa9fae13b556a2275192e7ab24ae29ba" }, "downloads": -1, "filename": "django-include-0.2.3.tar.gz", "has_sig": false, "md5_digest": "272dea71bb1a0f54d508c08e96b69a51", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13790, "upload_time": "2017-09-08T13:19:41", "url": "https://files.pythonhosted.org/packages/42/32/8ea503025f759fff69e226e8580437c68165b16a0209b6acda21855ecd22/django-include-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "871183631874e062f0eb3cbe8947c253", "sha256": "2ac4ca769c05d54c60d471b0f7d5ba749b9c62761ff86f4256b586c8701394a1" }, "downloads": -1, "filename": "django_include-0.2.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "871183631874e062f0eb3cbe8947c253", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10792, "upload_time": "2017-09-12T17:57:56", "url": "https://files.pythonhosted.org/packages/48/03/d9020a08fe342ca5ce394968576e6f0ec73e05d3eba94a7675f3de26e27f/django_include-0.2.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8eacf096fe58b373712a5761cc7105a1", "sha256": "e64eddd3844bcf17085087ad1a8e6f8e88b9e676c5ee4e06c272b5fdb05a1ef1" }, "downloads": -1, "filename": "django-include-0.2.4.tar.gz", "has_sig": false, "md5_digest": "8eacf096fe58b373712a5761cc7105a1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14125, "upload_time": "2017-09-12T17:57:58", "url": "https://files.pythonhosted.org/packages/33/e8/3e9f98b1a13ccf52a98ca19d4da6dfe53d14bd04acbf867e8d77cebb215b/django-include-0.2.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "871183631874e062f0eb3cbe8947c253", "sha256": "2ac4ca769c05d54c60d471b0f7d5ba749b9c62761ff86f4256b586c8701394a1" }, "downloads": -1, "filename": "django_include-0.2.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "871183631874e062f0eb3cbe8947c253", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10792, "upload_time": "2017-09-12T17:57:56", "url": "https://files.pythonhosted.org/packages/48/03/d9020a08fe342ca5ce394968576e6f0ec73e05d3eba94a7675f3de26e27f/django_include-0.2.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8eacf096fe58b373712a5761cc7105a1", "sha256": "e64eddd3844bcf17085087ad1a8e6f8e88b9e676c5ee4e06c272b5fdb05a1ef1" }, "downloads": -1, "filename": "django-include-0.2.4.tar.gz", "has_sig": false, "md5_digest": "8eacf096fe58b373712a5761cc7105a1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14125, "upload_time": "2017-09-12T17:57:58", "url": "https://files.pythonhosted.org/packages/33/e8/3e9f98b1a13ccf52a98ca19d4da6dfe53d14bd04acbf867e8d77cebb215b/django-include-0.2.4.tar.gz" } ] }