{ "info": { "author": "Tim Heap", "author_email": "tim@timheap.me", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "django-elasticfilter\n====================\n\nCreate Django forms that perform ElasticSearch queries and filters.\n\nInstalling\n----------\n\nInstall using pip::\n\n pip install django-elasticfilter\n\nUsing\n-----\n\nThe filter forms are standard Django forms, with some small extensions.\nThey inherit from `elasticfilter.filterform.FilterForm`.\nFields to search and filter on are declared as fields on the form,\nwhich should inherit from `elasticfilter.fields.BaseField`:\n\n.. code:: python\n\n from elasticfilter.filterform import FilterForm\n from elasticfilter.fields import Query, Filter\n\n class MyFilterForm(FilterForm):\n\n class FilterFormMeta:\n s = S().get_es(**ES_SETTINGS)\\\n .indexes('my-index')\\\n .doctypes('my-doctype')\n\n match = Query(required=False, fields=['_all', '_partial'])\n type = Filter(field='type')\n\n\nCustom queries and filters\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe provided ``Query`` and ``Filter`` classes are very basic.\nWriting custom ``Query`` and ``Filter`` classes is quite simple.\nFor example, to filter results based upon the ``ContentType`` of the model:\n\n.. code:: python\n\n from django import forms\n from django.db.models import get_models\n from elasticfilter.filterform import FilterForm\n from elasticfilter.fields import Filter\n\n class ContentTypeFilter(Filter, forms.ChoiceField):\n required = False\n\n def __init__(self, models=None, **kwargs):\n if models is None:\n models = get_models()\n\n self.choice_map = dict((model._meta.model_name, model)\n for model in models)\n\n choices = [(key, model.get_verbose_name())\n for key, model in self.choice_map.items()]\n kwargs.setdefault('choices', choices)\n super(ContentTypeFilter, self).__init__(**kwargs)\n\n def search(self, s, name, data):\n value = data.get(name, None)\n if not value:\n return s\n\n field = self.field or name\n content_type = ContentType.objects.get_for_model(self.choice_map[value])\n return s.filter(F(**{field: content_type.pk}))\n\n class MyFilterForm(FilterForm):\n content_type = ContentTypeFilter()", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/tim_heap/django-elasticfilter/", "keywords": null, "license": "BSD License", "maintainer": null, "maintainer_email": null, "name": "django-elasticfilter", "package_url": "https://pypi.org/project/django-elasticfilter/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-elasticfilter/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://bitbucket.org/tim_heap/django-elasticfilter/" }, "release_url": "https://pypi.org/project/django-elasticfilter/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Create forms that run Elasticsearch queries", "version": "0.1.0" }, "last_serial": 1213535, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "3c06b1052ac402690aa22d0b84a2de43", "sha256": "5580ade79cf24bc88bd3d4dd65a84faf387fa0d9243349e9c936c5aebc351050" }, "downloads": -1, "filename": "django-elasticfilter-0.1.0.tar.gz", "has_sig": false, "md5_digest": "3c06b1052ac402690aa22d0b84a2de43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3210, "upload_time": "2014-09-04T23:25:31", "url": "https://files.pythonhosted.org/packages/2f/ff/15321bbf5d6a64f4586fb653813b00abd861a1cffc4306a11d33f7dc3b8d/django-elasticfilter-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3c06b1052ac402690aa22d0b84a2de43", "sha256": "5580ade79cf24bc88bd3d4dd65a84faf387fa0d9243349e9c936c5aebc351050" }, "downloads": -1, "filename": "django-elasticfilter-0.1.0.tar.gz", "has_sig": false, "md5_digest": "3c06b1052ac402690aa22d0b84a2de43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3210, "upload_time": "2014-09-04T23:25:31", "url": "https://files.pythonhosted.org/packages/2f/ff/15321bbf5d6a64f4586fb653813b00abd861a1cffc4306a11d33f7dc3b8d/django-elasticfilter-0.1.0.tar.gz" } ] }