{ "info": { "author": "Brian Wawok", "author_email": "bwawok@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "Django-compoundqueryset\n------------\n\n|PyPi|\n\n.. |PyPi| image:: https://badge.fury.io/py/django-compoundqueryset.svg\n :target: https://pypi.python.org/pypi/django-compoundqueryset\n\nA little Django app allows for compound querysets between different tables.\nEspecially useful for pagination of said results.\n\n\n\nDjango versions supported: 1.8, 1.9, 1.10\n\nPython versions supported: 2.7, 3.3, 3.4, 3.5\n\n\n\nInstallation\n------------\n\nYou can obtain the source code for ``django-compoundqueryset`` from here:\n\n::\n\n https://github.com/brianwawok/django-compoundqueryset\n\n\nUsing `pip`:\n\n pip install django-compoundqueryset\n\nMotivation\n-----------\n\nSometimes you might want to combine two different tables with similar fields and show them to users. For example:\n\n.. code:: python\n\n from django.db import models\n\n\n\n class FirstModel(models.Model):\n age = models.IntegerField()\n name = models.TextField(max_length=100)\n color = models.TextField(max_length=100)\n\n\n class SecondModel(models.Model):\n age = models.IntegerField()\n name = models.TextField(max_length=100)\n size = models.IntegerField()\n\n\nAnd you want to paginate across them\n\n.. code:: python\n\n from django.core.paginator import Paginator\n from djcompoundqueryset import CompoundQueryset\n\n\n qs_1 = FirstModel.objects.order_by('age').all()\n qs_2 = SecondModel.objects.order_by('age').all()\n combined_queryset = qs_1 | qs_2\n\n p = Paginator(combined_queryset, 10)\n\nYou will get the dreaded error\n\n Merging 'QuerySet' classes must involve the same values in each case.\n\nNow with django-compoundqueryset, you can do:\n\n.. code:: python\n\n from django.core.paginator import Paginator\n from djcompoundqueryset import CompoundQueryset\n\n\n qs_1 = FirstModel.objects.order_by('age').all()\n qs_2 = SecondModel.objects.order_by('age').all()\n combined_queryset = CompoundQueryset(qs_1, qs_2, max_items=100)\n\n p = Paginator(combined_queryset, 10)\n\nYou can now iterate over these models in a view, showing the age. Max_items says you will\nnever use more than that many items, so limit the count a queries. Useful if you have\ncapped pagination.\n\n\nPerformance\n-----------\nThe goal is to beat the naive implementation (load all records into memory and deal with there), but\nwe may not beat a RawSQL union all monster. If performance is really important you may need to do that.\n\nIf used in a Django Paginator, we will normally do 1 count(*) query per queryset, and then only load the\nrequired records.\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/brianwawok/django-compoundqueryset/0.1.3", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/brianwawok/django-compoundqueryset", "keywords": "django,compound,queryset", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django-compoundqueryset", "package_url": "https://pypi.org/project/django-compoundqueryset/", "platform": "Any", "project_url": "https://pypi.org/project/django-compoundqueryset/", "project_urls": { "Download": "https://github.com/brianwawok/django-compoundqueryset/0.1.3", "Homepage": "https://github.com/brianwawok/django-compoundqueryset" }, "release_url": "https://pypi.org/project/django-compoundqueryset/0.1.3/", "requires_dist": null, "requires_python": null, "summary": "Allows for creation of compound querysets in Django.", "version": "0.1.3" }, "last_serial": 2258965, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "012c5ca580eb59c782a0acdd4383dffd", "sha256": "e87f50d245fa20826cf4ba0e461f88a9a737439d9e72795a907a72309043fef8" }, "downloads": -1, "filename": "django-compoundqueryset-0.1.zip", "has_sig": false, "md5_digest": "012c5ca580eb59c782a0acdd4383dffd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6316, "upload_time": "2016-07-10T20:34:47", "url": "https://files.pythonhosted.org/packages/43/24/1cceed65e43365b4cba39d6022de0493d517b7316738f8eba1d83095ced1/django-compoundqueryset-0.1.zip" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "d9ca425eada62fb50de042709c557518", "sha256": "c93c42164c72ceca82c15c17192faba6a728058397ee199a7a2665411e6687e4" }, "downloads": -1, "filename": "django-compoundqueryset-0.1.1.zip", "has_sig": false, "md5_digest": "d9ca425eada62fb50de042709c557518", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6404, "upload_time": "2016-07-10T20:39:18", "url": "https://files.pythonhosted.org/packages/a4/c0/a238adeb55e727cd806299a6b9fcbf6390885248ff820748688ef4f5894e/django-compoundqueryset-0.1.1.zip" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "9c47c5908973707edc643a11d621a490", "sha256": "53a7ac8ac9c1b606789f76c9420b61466749888d3f165d50634937714547e53e" }, "downloads": -1, "filename": "django-compoundqueryset-0.1.2.zip", "has_sig": false, "md5_digest": "9c47c5908973707edc643a11d621a490", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6658, "upload_time": "2016-08-02T18:59:18", "url": "https://files.pythonhosted.org/packages/d6/a0/b547c64ed744f7a5a675a1ce71494b0fb846ab0a761551ee42842ce0a24a/django-compoundqueryset-0.1.2.zip" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "e4403abf839ddc2fc3a491bab0abc8f3", "sha256": "a103efdbab41a760e0768927ca04edc9821b6182df471efbc85e3b1c34354eee" }, "downloads": -1, "filename": "django-compoundqueryset-0.1.3.zip", "has_sig": false, "md5_digest": "e4403abf839ddc2fc3a491bab0abc8f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7039, "upload_time": "2016-08-02T23:42:18", "url": "https://files.pythonhosted.org/packages/52/81/359d39f813b3e60f7ba513da40a3165745632cb81e8f857d16461aa61d46/django-compoundqueryset-0.1.3.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e4403abf839ddc2fc3a491bab0abc8f3", "sha256": "a103efdbab41a760e0768927ca04edc9821b6182df471efbc85e3b1c34354eee" }, "downloads": -1, "filename": "django-compoundqueryset-0.1.3.zip", "has_sig": false, "md5_digest": "e4403abf839ddc2fc3a491bab0abc8f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7039, "upload_time": "2016-08-02T23:42:18", "url": "https://files.pythonhosted.org/packages/52/81/359d39f813b3e60f7ba513da40a3165745632cb81e8f857d16461aa61d46/django-compoundqueryset-0.1.3.zip" } ] }