{ "info": { "author": "Claudio Omar Melendrez Baeza", "author_email": "claudio.melendrez@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Plugins", "Framework :: Django :: 1.10", "Framework :: Django :: 1.8", "Framework :: Django :: 1.9", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development" ], "description": "==============\nDjango GroupBy\n==============\n\n.. image:: https://img.shields.io/github/license/kako-nawao/django-group-by.svg\n :target: http://www.opensource.org/licenses/MIT\n\n.. image:: https://img.shields.io/pypi/pyversions/django-group-by.svg\n :target: https://pypi.python.org/pypi/django-group-by\n.. image:: https://img.shields.io/pypi/v/django-group-by.svg\n :target: https://pypi.python.org/pypi/django-group-by\n\n.. image:: https://img.shields.io/travis/kako-nawao/django-group-by.svg\n :target: https://travis-ci.org/kako-nawao/django-group-by\n.. image:: https://img.shields.io/codecov/c/github/kako-nawao/django-group-by.svg\n :target: https://codecov.io/gh/kako-nawao/django-group-by\n\nThis package provides a mixin for Django QuerySets that adds a method ``group_by`` that\nbehaves mostly like the ``values`` method, but with one difference: its iterator does not\nreturn dictionaries, but a *model-like object with model instances for related values*.\n\nInstallation\n============\n\nInstall from PyPI::\n\n pip install django-group-by\n\nCompatibility\n~~~~~~~~~~~~~\n\nThis package is compatible with Django 1.8, 1.9 and 1.10, and Python versions 2.7, 3.4, 3.5 and 3.6.\nProbably others, but those 12 combinations are the ones against which we build (by Travis CI).\n\n\nUsage\n=====\n\nCreate a QuerySet subclass with the ``GroupByMixin`` to use in a model's manager::\n\n # models.py\n\n from django.db import models\n from django.db.models.query import QuerySet\n from django_group_by import GroupByMixin\n\n class BookQuerySet(QuerySet, GroupByMixin):\n pass\n\n class Book(Model):\n objects = BookQuerySet.as_manager()\n\n title = models.CharField(max_length=100)\n author = models.ForeignKey('another_app.Author')\n publication_date = models.DateField()\n ...\n\nThen use it just like ``values``, and you'll get a similar query set::\n\n >>> some_rows = Book.objects.group_by('title', 'author', 'author__nationality').distinct()\n >>> some_rows.count()\n 4\n\nThe difference is that every row is not a dictionary but an AggregatedGroup instance, with only the grouped fields::\n\n >>> row = some_rows[0]\n >>> row\n \n >>> row.title\n The Colour of Magic\n >>> row.publication_date\n *** AttributeError: 'AggregatedGroup' object has no attribute 'publication_date'\n\nBut of course the main advantage is that you also get related model instances, as far as you want::\n\n >>> row.author\n \n >>> row.author_nationality\n \n\n\nRelated Model ID Only\n~~~~~~~~~~~~~~~~~~~~~\n\nThe previous example shows a difference in behaviour from Django's ``values``: we're grouping by the foreign key\n*author*, but instead of getting only the ID we get the full instance. Why? Because it's more useful, and I\nthink that getting *{'author': 5}* as a result is just weird.\n\nIf you just want the ID you can specify it::\n\n >>> some_rows = Book.objects.group_by('title', 'author_id', 'author__nationality_id').distinct()\n\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kako-nawao/django-group-by", "keywords": "django grouping values models", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-group-by", "package_url": "https://pypi.org/project/django-group-by/", "platform": "", "project_url": "https://pypi.org/project/django-group-by/", "project_urls": { "Homepage": "https://github.com/kako-nawao/django-group-by" }, "release_url": "https://pypi.org/project/django-group-by/0.3.1/", "requires_dist": null, "requires_python": "", "summary": "Group by arbitrary model fields", "version": "0.3.1" }, "last_serial": 2700897, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "672023cd81735515823fa2566e005ace", "sha256": "2fbbaadddec7f2b6f9f5ff55513c1deac33acabc34e59cedc6b2c88de0037234" }, "downloads": -1, "filename": "django_group_by-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "672023cd81735515823fa2566e005ace", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4899, "upload_time": "2016-05-29T01:37:17", "url": "https://files.pythonhosted.org/packages/2b/6c/356359bb3a48d53f0fb361c132676b46cfad35938b7b52e5c2177c4198ff/django_group_by-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "16c629ae2f0b75db062456f33dcdcc61", "sha256": "628991b29ade2730b3316c9eeb32d1da0286c86edceaee548d98c77e33906ba2" }, "downloads": -1, "filename": "django_group_by-0.1.0.tar.gz", "has_sig": false, "md5_digest": "16c629ae2f0b75db062456f33dcdcc61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4629, "upload_time": "2016-05-29T01:37:22", "url": "https://files.pythonhosted.org/packages/97/2d/60d017e2cfa6e2a3b62b67a044ec2d6d27efbb8ee2a1b2f698a76e0d54ae/django_group_by-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "b426ee3c93139184e1006c606fbb134f", "sha256": "d8b1019a7da1ac46afe3ddc8595c9e44f53bbd87e1513ca0a2e02154c40e9b2f" }, "downloads": -1, "filename": "django_group_by-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b426ee3c93139184e1006c606fbb134f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6879, "upload_time": "2016-05-29T01:41:25", "url": "https://files.pythonhosted.org/packages/54/b8/f164fab12da2bf13d2b7f72396ea37e829cddd059f5584fd8002d2275e93/django_group_by-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0979caa02f89cb552c040c0c948d4353", "sha256": "71a18b2e602b677d66bbe2e7af4688021a21bad4ff66a555b6177c030f59a9a9" }, "downloads": -1, "filename": "django_group_by-0.1.1.tar.gz", "has_sig": false, "md5_digest": "0979caa02f89cb552c040c0c948d4353", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4888, "upload_time": "2016-05-29T01:41:29", "url": "https://files.pythonhosted.org/packages/b9/65/9822ef79ab8387564f22cd0870775a9e479a51d8540892218fced144bd41/django_group_by-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "31f6f5f9b3e46eeebee501b2787e7fe1", "sha256": "af50848bf692473e02c8f612fb2feda434314f71960204ac275b56fd8021c74d" }, "downloads": -1, "filename": "django_group_by-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "31f6f5f9b3e46eeebee501b2787e7fe1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8307, "upload_time": "2016-05-30T22:37:44", "url": "https://files.pythonhosted.org/packages/91/33/3dd79ab2fa89ba4f67c70c640d878488edc4a67a65e8818fcf45640d58ff/django_group_by-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2b2b0cad59129d792d8a91a6ceeb0521", "sha256": "ee186b7f6b9d7a0730bd40750a7151992aff28418c89fec87c873895f38f75c6" }, "downloads": -1, "filename": "django_group_by-0.2.0.tar.gz", "has_sig": false, "md5_digest": "2b2b0cad59129d792d8a91a6ceeb0521", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5359, "upload_time": "2016-05-30T22:38:02", "url": "https://files.pythonhosted.org/packages/f7/6b/f5c70f397e1a931e788e466bf6e4581b6a444a64f8cae4d2e43fd5bd61e4/django_group_by-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "74e4d78a8bbdc55d1530a6e775a4c30b", "sha256": "b2707941a25a1d86e7cf8f296ca7130be9a49365e428aba59f1cb0b4d227577d" }, "downloads": -1, "filename": "django_group_by-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "74e4d78a8bbdc55d1530a6e775a4c30b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8500, "upload_time": "2016-05-30T22:45:01", "url": "https://files.pythonhosted.org/packages/d9/95/f1617cf675d924c5208fab6c95a3941811b4c3d9437563801b6a928a9bbe/django_group_by-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "50a4ca350da75f8d8fc69bdfd76d9a04", "sha256": "84ceb94b8bacd9ccdeec527be2700929ae841c9090f6717536ecacdac0b2031a" }, "downloads": -1, "filename": "django_group_by-0.2.1.tar.gz", "has_sig": false, "md5_digest": "50a4ca350da75f8d8fc69bdfd76d9a04", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5463, "upload_time": "2016-05-30T22:49:54", "url": "https://files.pythonhosted.org/packages/33/a1/84f6e7b75dd55172470489fa007ef9176a1f873dac5c87189cd08b024ade/django_group_by-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "0302d42bdf5c82dbd50af26c4c71cde8", "sha256": "4f7e72d9693645a0641809230893376e2cc4620f92bbd5c1444a39ac6845d716" }, "downloads": -1, "filename": "django_group_by-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0302d42bdf5c82dbd50af26c4c71cde8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8555, "upload_time": "2016-06-21T17:23:17", "url": "https://files.pythonhosted.org/packages/14/26/dfdf9d1ca0d6b9a5830e91340d724d67bb5c8042b39ea7c04c634ba2a0bc/django_group_by-0.2.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5bfa3042e13a2a9c8ce3d3097bac758b", "sha256": "19b303d3a0bbff97512773e008f270289b4bbac068d328dae6663cabfad72d19" }, "downloads": -1, "filename": "django_group_by-0.2.2.tar.gz", "has_sig": false, "md5_digest": "5bfa3042e13a2a9c8ce3d3097bac758b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5458, "upload_time": "2016-06-21T17:23:21", "url": "https://files.pythonhosted.org/packages/b3/b4/3f525af99621f445ddbd6156c90c2d7ac61eae560e198de2d93ec682761e/django_group_by-0.2.2.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "35df711f9b8d4d030a241f9de56471f9", "sha256": "a0d5b6c83bfc56aaaaef2ef6d19d5bd0c80ccd5fd1294bb655212ded795517ae" }, "downloads": -1, "filename": "django_group_by-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "35df711f9b8d4d030a241f9de56471f9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8566, "upload_time": "2016-06-21T19:10:51", "url": "https://files.pythonhosted.org/packages/bd/15/0ad8b01ca674559c121bece16944455319877f4d1915f6fb543b6a90f6d5/django_group_by-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a69e3a2b0a7812e94fd05a479d2bfec1", "sha256": "09fff4f255b4e044fbfeb349ff2a06ec26cf237fab6e13648f498eb38d4b5492" }, "downloads": -1, "filename": "django_group_by-0.3.0.tar.gz", "has_sig": false, "md5_digest": "a69e3a2b0a7812e94fd05a479d2bfec1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5478, "upload_time": "2016-06-21T19:10:55", "url": "https://files.pythonhosted.org/packages/1b/b7/a2e8c5461fb4057609350b27de8a14999afae856bdc219e2db90818e1eb7/django_group_by-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "d5547d8dde8637fcb8d6d67ccaee81a8", "sha256": "b4e554c0eb9eed39c0cdc64de20fa7b2906ad92408d6a47b5bc55764711fc2e5" }, "downloads": -1, "filename": "django_group_by-0.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d5547d8dde8637fcb8d6d67ccaee81a8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8616, "upload_time": "2017-03-12T19:14:00", "url": "https://files.pythonhosted.org/packages/ef/ea/e44706b97580d021d6e175c2a186e05c6eb05ae8b034cc3d490b99b32862/django_group_by-0.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e158d8388867f1eb7fbf8b3efc40a4e9", "sha256": "4f1a17b61c7d16924a1c7afcea3ceb42c217c5c845fd03ad6e54fda4b6c710db" }, "downloads": -1, "filename": "django_group_by-0.3.1.tar.gz", "has_sig": false, "md5_digest": "e158d8388867f1eb7fbf8b3efc40a4e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5456, "upload_time": "2017-03-12T19:14:01", "url": "https://files.pythonhosted.org/packages/c8/0a/b98b8fbb9cd8879e13b5bfebcdda90e5d2490b90bacfd272dbfc6f7d6ad7/django_group_by-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d5547d8dde8637fcb8d6d67ccaee81a8", "sha256": "b4e554c0eb9eed39c0cdc64de20fa7b2906ad92408d6a47b5bc55764711fc2e5" }, "downloads": -1, "filename": "django_group_by-0.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d5547d8dde8637fcb8d6d67ccaee81a8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8616, "upload_time": "2017-03-12T19:14:00", "url": "https://files.pythonhosted.org/packages/ef/ea/e44706b97580d021d6e175c2a186e05c6eb05ae8b034cc3d490b99b32862/django_group_by-0.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e158d8388867f1eb7fbf8b3efc40a4e9", "sha256": "4f1a17b61c7d16924a1c7afcea3ceb42c217c5c845fd03ad6e54fda4b6c710db" }, "downloads": -1, "filename": "django_group_by-0.3.1.tar.gz", "has_sig": false, "md5_digest": "e158d8388867f1eb7fbf8b3efc40a4e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5456, "upload_time": "2017-03-12T19:14:01", "url": "https://files.pythonhosted.org/packages/c8/0a/b98b8fbb9cd8879e13b5bfebcdda90e5d2490b90bacfd272dbfc6f7d6ad7/django_group_by-0.3.1.tar.gz" } ] }