{ "info": { "author": "Philip Neustrom", "author_email": "philipn@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Internet :: WWW/HTTP" ], "description": "`django-rest-framework-chain` is an extension to Django REST Framework that allows arbitrary chaining of both relations and lookup filters.\n\n.. image:: https://secure.travis-ci.org/philipn/django-rest-framework-chain.png?branch=master\n :target: http://travis-ci.org/philipn/django-rest-framework-chain\n\nInstallation\n------------\n\n.. code-block:: bash\n\n $ pip install djangorestframework-chain\n\nRequirements\n------------\n\n* Python 2.6+\n* Django 1.4.5+\n\nUsage\n-----\n\nChaining filtering through relations\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTo enable chained filtering through relations:\n\n.. code-block:: python\n\n from rest_framework import viewsets\n import django_filters\n from rest_framework_chain import ChainedFilterSet, RelatedFilter\n\n # Just a regular FilterSet\n class UserFilter(django_filters.FilterSet):\n username = django_filters.CharFilter(name='username')\n ...\n\n class PageFilter(ChainedFilterSet):\n title = django_filters.CharFilter(name='title')\n author = RelatedFilter(UserFilter, name='author')\n\n # Then just use the PageFilter as you would any other FilterSet:\n\n class PageView(viewsets.ModelViewSet):\n ...\n filter_class = PageFilter\n\nthen we can automatically chain our filters through the ``author`` relation, as so::\n\n /api/page/?author__username=philipn\n\n\nAllowing any lookup type on a field\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWe can use the ``AllLookupsFilter`` to allow all possible lookup types on a particular\nfield. While we could otherwise specify these by hand, e.g.:\n\n.. code-block:: python\n\n class ProductFilter(django_filters.FilterSet):\n min_price = django_filters.NumberFilter(name=\"price\", lookup_type='gte')\n ...\n\nto allow the ``price__gte`` lookup. But this gets cumbersome, and we sometimes want to\nallow any possible lookups on particular fields. We do this by using ``AllLookupsFilter``:\n\n.. code-block:: python\n\n from rest_framework import viewsets\n import django_filters\n from rest_framework_chain import ChainedFilterSet, AllLookupsFilter\n\n class PageFilter(ChainedFilterSet):\n title = AllLookupsFilter(name='title')\n ...\n\nthen we can use any possible lookup on the ``title`` field, e.g.::\n\n /api/page/?title__icontains=park\n\nor ::\n\n /api/page/?title__startswith=The\n\nand also filter on the default lookup (``exact``), as usual::\n\n /api/page/?title=The%20Park\n\nCombining RelatedFilter and AllLookupsFilter\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWe can combine ``RelatedFilter`` and ``AllLookupsFilter``:\n\n.. code-block:: python\n\n from rest_framework import viewsets\n import django_filters\n from rest_framework_chain import ChainedFilterSet, RelatedFilter\n\n class PageFilter(ChainedFilterSet):\n title = django_filters.CharFilter(name='title')\n author = RelatedFilter(UserFilter, name='author')\n\n # Just a regular FilterSet\n class UserFilter(ChainedFilterSet):\n username = AllLookupsFilter(name='username')\n ...\n\nthen we can filter like so::\n\n /api/page/?author__username__icontains=john\n\nMore information on RelatedFilter\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nRecursive relations are supported. You will need to specify the full module\npath in the ``RelatedFilter`` definition in some cases, e.g.:\n\n.. code-block:: python\n\n class PersonFilter(ChainedFilterSet):\n name = AllLookupsFilter(name='name')\n best_friend = RelatedFilter('people.views.PersonFilter', name='best_friend')\n\n class Meta:\n model = Person \n\nLicense\n-------\nCopyright (c) 2013 Philip Neustrom \n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n", "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/philipn/django-rest-framework-chain", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "djangorestframework-chain", "package_url": "https://pypi.org/project/djangorestframework-chain/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/djangorestframework-chain/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/philipn/django-rest-framework-chain" }, "release_url": "https://pypi.org/project/djangorestframework-chain/0.1.3/", "requires_dist": null, "requires_python": null, "summary": "Chained relations and filtering for Django REST Framework", "version": "0.1.3" }, "last_serial": 944441, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "f11539912114c3ffb80b48c5938f11e9", "sha256": "8faffddb9852d08339773d0dcca5647d4d514575835ac74551ca9ce18ff57704" }, "downloads": -1, "filename": "djangorestframework-chain-0.1.0.tar.gz", "has_sig": false, "md5_digest": "f11539912114c3ffb80b48c5938f11e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4364, "upload_time": "2013-12-12T04:17:39", "url": "https://files.pythonhosted.org/packages/7f/0f/ddd4a073ba0390628879145b40d78fd234f56b2b96a48087eac2ed68bd64/djangorestframework-chain-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "1d7404797eb0d936f28c5ebe41ae3f9e", "sha256": "4487d651080bdd5a40860794b79d175ffea30be13b4616e1c681faf3ebdcc7a1" }, "downloads": -1, "filename": "djangorestframework-chain-0.1.1.tar.gz", "has_sig": false, "md5_digest": "1d7404797eb0d936f28c5ebe41ae3f9e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7689, "upload_time": "2013-12-12T05:12:20", "url": "https://files.pythonhosted.org/packages/20/00/d2a5ef15951abe2fd1e84907fc41a0c424f0be92bcedf9169dab69da589a/djangorestframework-chain-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "80fb2a5522f5b9320010cd42a2236499", "sha256": "f465a104eb8101c0cc13728c7221a2ef83e266170461774ebe299aa014eed17a" }, "downloads": -1, "filename": "djangorestframework-chain-0.1.2.tar.gz", "has_sig": false, "md5_digest": "80fb2a5522f5b9320010cd42a2236499", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7879, "upload_time": "2013-12-13T06:50:27", "url": "https://files.pythonhosted.org/packages/2e/68/2d43946fc8f77e3381dd84d19702c6d94b91b2790d40bb00b6a3b4d66fac/djangorestframework-chain-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "6af90db8685cd256b9fad69d14964a06", "sha256": "8940e20766f070ec5d8f920c528e1fbf910ff170bc8a0cbfb80237ad4475f954" }, "downloads": -1, "filename": "djangorestframework-chain-0.1.3.tar.gz", "has_sig": false, "md5_digest": "6af90db8685cd256b9fad69d14964a06", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9011, "upload_time": "2013-12-14T12:19:53", "url": "https://files.pythonhosted.org/packages/2d/e8/3fec50f70103d6c772cebb9f36731c39d6f5b48de7982d5343528b4ff997/djangorestframework-chain-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6af90db8685cd256b9fad69d14964a06", "sha256": "8940e20766f070ec5d8f920c528e1fbf910ff170bc8a0cbfb80237ad4475f954" }, "downloads": -1, "filename": "djangorestframework-chain-0.1.3.tar.gz", "has_sig": false, "md5_digest": "6af90db8685cd256b9fad69d14964a06", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9011, "upload_time": "2013-12-14T12:19:53", "url": "https://files.pythonhosted.org/packages/2d/e8/3fec50f70103d6c772cebb9f36731c39d6f5b48de7982d5343528b4ff997/djangorestframework-chain-0.1.3.tar.gz" } ] }