{ "info": { "author": "Preston Holmes", "author_email": "preston@ptone.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Topic :: Utilities" ], "description": "django-predicate\n================\n\ndjango-predicate provides a Q like object to facilitate the question: \"would\nthis model instance be part of a query\" but without running the query or even\nsaving the object.\n\nQuickstart\n----------\n\nInstall django-predicate:\n\n.. code-block:: console\n\n pip install django-predicate\n\nThen use the ``P`` object just as you would ``Q`` objects:\n\n.. code-block:: python\n\n from predicate import P\n\n p = P(some_field__startswith=\"hello\", age__gt=20)\n\nYou can then call the ``eval`` method with a model instance to check whether it\npasses the conditions:\n\n.. code-block:: python\n\n model_instance = MyModel(some_field=\"hello there\", age=21)\n other_model_instance = MyModel(some_field=\"hello there\", age=10)\n p.eval(model_instance)\n >>> True\n p.eval(other_model_instance)\n >>> False\n\nor you can use Python's ``in`` operator.\n\n.. code-block:: python\n\n model_instance in p\n >>> True\n\nEven though a predicate is not a true container class - it can be used as (and\nwas designed as being) a virtual \"set\" of objects that meets some condiiton.\n\nLike Q objects, P objects can be ``&``'ed and ``|``'ed together to form more\ncomplex logic groupings.\n\nIn fact, P objects are actually a subclass of Q objects, so you can use them in\nqueryset filter statements:\n\n.. code-block:: python\n\n qs = MyModel.objects.filter(p)\n\n\nP objects also support ``QuerySet``-like filtering operations that can be\napplied to an arbitrary iterable: ``P.get(iterable)``, ``P.filter(iterable)``,\nand ``P.exclude(iterable)``:\n\n.. code-block:: python\n\n model_instance = MyModel(some_field=\"hello there\", age=21)\n other_model_instance = MyModel(some_field=\"hello there\", age=10)\n p.filter([model_instance, other_model_instance]) == [model_instance]\n >>> True\n p.get([model_instance, other_model_instance]) == model_instance\n >>> True\n p.exclude([model_instance, other_model_instance]) == [other_model_instance]\n >>> True\n\n\nIf you have a situation where you want to use querysets and predicates based on\nthe same conditions, it is far better to start with the predicate. Because of\nthe way querysets assume a SQL context, it is non-trivial to reverse engineer\nthem back into a predicate. However as seen above, it is very straightforward\nto create a queryset based on a predicate.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/ptone/django-predicate", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-predicate", "package_url": "https://pypi.org/project/django-predicate/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-predicate/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/ptone/django-predicate" }, "release_url": "https://pypi.org/project/django-predicate/1.4.0/", "requires_dist": null, "requires_python": null, "summary": "A predicate class constructed like Django Q objects, used to test whether a new or modified model would match a query", "version": "1.4.0" }, "last_serial": 2055593, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "cda4d67441836f18ac7607f2918d66cd", "sha256": "07783f738effc9d2cb44f8ec26e351074e1025338f95c3261b2def961795a51d" }, "downloads": -1, "filename": "django-predicate-0.1.tar.gz", "has_sig": false, "md5_digest": "cda4d67441836f18ac7607f2918d66cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11951, "upload_time": "2012-08-15T06:06:12", "url": "https://files.pythonhosted.org/packages/10/df/713fcf92cd6aa0b1da2719263bd4d2cdb105bd86261a4180d58da6e6f435/django-predicate-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "a27061cd3d739b8496f7777f19a336b9", "sha256": "d6c262b894455a49f5ed8a067c0af1d4b3dfa9f365532ded53240bf0ee6f9429" }, "downloads": -1, "filename": "django-predicate-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a27061cd3d739b8496f7777f19a336b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12259, "upload_time": "2012-09-02T14:26:43", "url": "https://files.pythonhosted.org/packages/b5/40/1fe2e438772560a8ce3f4cf69826781155911b7741a2ca04cc426f44e5eb/django-predicate-0.1.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "8ca0f3204b27cb8c43d6b78fee560324", "sha256": "60a39f6ab110e41edbf4b6e4da28ab4a99afafbe99875e3afc463b110e3ebaa3" }, "downloads": -1, "filename": "django-predicate-1.0.0.tar.gz", "has_sig": false, "md5_digest": "8ca0f3204b27cb8c43d6b78fee560324", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6685, "upload_time": "2016-01-06T20:31:43", "url": "https://files.pythonhosted.org/packages/f3/59/05d2c5d28a19d0bf36970b19c50e7e4c36261f5d7b70089a7074663397bc/django-predicate-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "24cd8e3762171f5dcdf2ffce0a816860", "sha256": "e4e177cdee32d037f25f13ab846c3ed75117dbba2ee032a1b510f6e1dc9de16e" }, "downloads": -1, "filename": "django-predicate-1.0.1.tar.gz", "has_sig": false, "md5_digest": "24cd8e3762171f5dcdf2ffce0a816860", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12887, "upload_time": "2016-01-14T01:24:46", "url": "https://files.pythonhosted.org/packages/7b/8d/2505ea959f2fc29ef0377a40941020bc45107712e5e998cf157e330cf014/django-predicate-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "4ddfb2030cd1dff4ef4cc8e95df819e4", "sha256": "14633c4ac88d0a3b6c6c1a0531a04752a7a9a0b0ac86dcdf80281624b4cfe30e" }, "downloads": -1, "filename": "django-predicate-1.1.0.tar.gz", "has_sig": false, "md5_digest": "4ddfb2030cd1dff4ef4cc8e95df819e4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14296, "upload_time": "2016-01-23T01:33:04", "url": "https://files.pythonhosted.org/packages/c9/25/3f70e7947ecd978714a82598e280ea0215feb75ce74f61552229800e41e8/django-predicate-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "5bb96ea3a44e4793eb1c15f98e3ebfe5", "sha256": "dc4d6281ec6956945c62076455dced01bb95f70ded23332d63eedacba9645a1b" }, "downloads": -1, "filename": "django-predicate-1.2.0.tar.gz", "has_sig": false, "md5_digest": "5bb96ea3a44e4793eb1c15f98e3ebfe5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14994, "upload_time": "2016-02-06T07:33:37", "url": "https://files.pythonhosted.org/packages/2f/45/77fbc6c267501dcf66de83cba1ec65b8162846c09dd81ce5d4d46a9a5a15/django-predicate-1.2.0.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "4b37bb18737185c6a679941b03e704b2", "sha256": "e4527481278b448128d15bef78c8b1dcada3f6b9be32854c680c032558b6c3e9" }, "downloads": -1, "filename": "django-predicate-1.2.1.tar.gz", "has_sig": false, "md5_digest": "4b37bb18737185c6a679941b03e704b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24552, "upload_time": "2016-02-17T00:51:19", "url": "https://files.pythonhosted.org/packages/2f/99/7affe12f0b60210d7e0c48cb0e0e44f6c0d072ec9562209ae700b452afed/django-predicate-1.2.1.tar.gz" } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "b75cb542fca9e3f4c8902f9e7c6f3326", "sha256": "c5bc824251518bd8865d44d4a35fff5dc8620f2311935409dfe2bc48077ff089" }, "downloads": -1, "filename": "django-predicate-1.2.2.tar.gz", "has_sig": false, "md5_digest": "b75cb542fca9e3f4c8902f9e7c6f3326", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24854, "upload_time": "2016-02-19T23:39:03", "url": "https://files.pythonhosted.org/packages/7b/83/67df53aaa5b19b817a5bc8fc6976d8854cef8de8ec1c282f0638e7c4b743/django-predicate-1.2.2.tar.gz" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "d5a5b14daeef76eafefea09b03acdb36", "sha256": "edb71f2a1b1eae60bccfae8d6f310214bad61bd16efaf9c8d57a467fb26165d9" }, "downloads": -1, "filename": "django-predicate-1.3.0.tar.gz", "has_sig": false, "md5_digest": "d5a5b14daeef76eafefea09b03acdb36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25799, "upload_time": "2016-02-23T01:36:18", "url": "https://files.pythonhosted.org/packages/6d/a7/100a20c766c2aff3aecb51be2aa3abd8c9443d6f90da4949ec26c4c034c8/django-predicate-1.3.0.tar.gz" } ], "1.3.1": [ { "comment_text": "", "digests": { "md5": "71136b7499dc7fff4671e5a1fb9ff9ab", "sha256": "bc72fff57ad0e94cd409a91785dc8e5f92dfdd39d42751fd886b238409656e8b" }, "downloads": -1, "filename": "django-predicate-1.3.1.tar.gz", "has_sig": false, "md5_digest": "71136b7499dc7fff4671e5a1fb9ff9ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26237, "upload_time": "2016-02-28T02:29:41", "url": "https://files.pythonhosted.org/packages/f0/ee/920e6c5babb1eb41a72ebe2f16f5a1ed6e1771116c1ba6eeb4878a28f67a/django-predicate-1.3.1.tar.gz" } ], "1.4.0": [ { "comment_text": "", "digests": { "md5": "cca5a389c0cd182474a97449b669a673", "sha256": "689ee52b7b796e49cb07226b4f90b77a81607fd80310390d654d4c1eb044e6bf" }, "downloads": -1, "filename": "django-predicate-1.4.0.tar.gz", "has_sig": false, "md5_digest": "cca5a389c0cd182474a97449b669a673", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 44980, "upload_time": "2016-04-09T23:33:02", "url": "https://files.pythonhosted.org/packages/e2/ed/9ca045d3878bbc1426690e8611238846a287d7d225d6eefece3735c93720/django-predicate-1.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cca5a389c0cd182474a97449b669a673", "sha256": "689ee52b7b796e49cb07226b4f90b77a81607fd80310390d654d4c1eb044e6bf" }, "downloads": -1, "filename": "django-predicate-1.4.0.tar.gz", "has_sig": false, "md5_digest": "cca5a389c0cd182474a97449b669a673", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 44980, "upload_time": "2016-04-09T23:33:02", "url": "https://files.pythonhosted.org/packages/e2/ed/9ca045d3878bbc1426690e8611238846a287d7d225d6eefece3735c93720/django-predicate-1.4.0.tar.gz" } ] }