{"id":16641184,"url":"https://github.com/barseghyanartur/django-mongoengine-filter","last_synced_at":"2025-03-16T22:31:27.162Z","repository":{"id":57420906,"uuid":"177591120","full_name":"barseghyanartur/django-mongoengine-filter","owner":"barseghyanartur","description":"django-filter for MongoEngine","archived":false,"fork":false,"pushed_at":"2024-07-12T10:14:43.000Z","size":129,"stargazers_count":13,"open_issues_count":6,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-27T14:58:35.782Z","etag":null,"topics":["django","django-filter","mongoengine"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/django-mongoengine-filter/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/barseghyanartur.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE_GPL2.0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-25T13:23:24.000Z","updated_at":"2023-08-04T13:19:36.000Z","dependencies_parsed_at":"2023-01-31T17:31:17.737Z","dependency_job_id":null,"html_url":"https://github.com/barseghyanartur/django-mongoengine-filter","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barseghyanartur%2Fdjango-mongoengine-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barseghyanartur%2Fdjango-mongoengine-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barseghyanartur%2Fdjango-mongoengine-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barseghyanartur%2Fdjango-mongoengine-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barseghyanartur","download_url":"https://codeload.github.com/barseghyanartur/django-mongoengine-filter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830952,"owners_count":20354854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-filter","mongoengine"],"created_at":"2024-10-12T07:45:43.161Z","updated_at":"2025-03-16T22:31:26.797Z","avatar_url":"https://github.com/barseghyanartur.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=========================\ndjango-mongoengine-filter\n=========================\n``django-mongoengine-filter`` is a reusable Django application for allowing\nusers to filter `mongoengine querysets`_ dynamically. It's very similar to\npopular ``django-filter`` library and is designed to be used as a drop-in\nreplacement (as much as it's possible) strictly tied to ``MongoEngine``.\n\nFull documentation on `Read the docs`_.\n\n.. image:: https://img.shields.io/pypi/v/django-mongoengine-filter.svg\n   :target: https://pypi.python.org/pypi/django-mongoengine-filter\n   :alt: PyPI Version\n\n.. image:: https://img.shields.io/pypi/pyversions/django-mongoengine-filter.svg\n    :target: https://pypi.python.org/pypi/django-mongoengine-filter/\n    :alt: Supported Python versions\n\n.. image:: https://github.com/barseghyanartur/django-mongoengine-filter/workflows/test/badge.svg\n   :target: https://github.com/barseghyanartur/django-mongoengine-filter/actions\n   :alt: Build Status\n\n.. image:: https://readthedocs.org/projects/django-mongoengine-filter/badge/?version=latest\n    :target: http://django-mongoengine-filter.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n.. image:: https://img.shields.io/badge/license-GPL--2.0--only%20OR%20LGPL--2.1--or--later-blue.svg\n   :target: https://github.com/barseghyanartur/django-mongoengine-filter/#License\n   :alt: GPL-2.0-only OR LGPL-2.1-or-later\n\n.. image:: https://coveralls.io/repos/github/barseghyanartur/django-mongoengine-filter/badge.svg?branch=master\n    :target: https://coveralls.io/github/barseghyanartur/django-mongoengine-filter?branch=master\n    :alt: Coverage\n\nRequirements\n============\n* Python 3.7, 3.8, 3.9, 3.10 or 3.11.\n* MongoDB 3.x, 4.x, 5.x.\n* Django 2.2, 3.0, 3.1, 3.2, 4.0 or 4.1.\n\nInstallation\n============\nInstall using pip:\n\n.. code-block:: sh\n\n    pip install django-mongoengine-filter\n\nOr latest development version:\n\n.. code-block:: sh\n\n    pip install https://github.com/barseghyanartur/django-mongoengine-filter/archive/master.zip\n\nUsage\n=====\n**Sample document**\n\n.. code-block:: python\n\n    from mongoengine import fields, document\n    from .constants import PROFILE_TYPES, PROFILE_TYPE_FREE, GENDERS, GENDER_MALE\n\n    class Person(document.Document):\n\n        name = fields.StringField(\n            required=True,\n            max_length=255,\n            default=\"Robot\",\n            verbose_name=\"Name\"\n        )\n        age = fields.IntField(required=True, verbose_name=\"Age\")\n        num_fingers = fields.IntField(\n            required=False,\n            verbose_name=\"Number of fingers\"\n        )\n        profile_type = fields.StringField(\n            required=False,\n            blank=False,\n            null=False,\n            choices=PROFILE_TYPES,\n            default=PROFILE_TYPE_FREE,\n        )\n        gender = fields.StringField(\n            required=False,\n            blank=False,\n            null=False,\n            choices=GENDERS,\n            default=GENDER_MALE\n        )\n\n        def __str__(self):\n            return self.name\n\n**Sample filter**\n\n.. code-block:: python\n\n    import django_mongoengine_filter\n\n    class PersonFilter(django_mongoengine_filter.FilterSet):\n\n        profile_type = django_mongoengine_filter.StringFilter()\n        ten_fingers = django_mongoengine_filter.MethodFilter(\n            action=\"ten_fingers_filter\"\n        )\n\n        class Meta:\n            model = Person\n            fields = [\"profile_type\", \"ten_fingers\"]\n\n        def ten_fingers_filter(self, queryset, name, value):\n            if value == 'yes':\n                return queryset.filter(num_fingers=10)\n            return queryset\n\n**Sample view**\n\nWith function-based views:\n\n.. code-block:: python\n\n    def person_list(request):\n        filter = PersonFilter(request.GET, queryset=Person.objects)\n        return render(request, \"dfm_app/person_list.html\", {\"object_list\": filter.qs})\n\nOr class-based views:\n\n.. code-block:: python\n\n    from django_mongoengine_filter.views import FilterView\n\n    class PersonListView(FilterView):\n\n        filterset_class = PersonFilter\n        template_name = \"dfm_app/person_list.html\"\n\n**Sample template**\n\n.. code-block:: html\n\n    \u003cul\u003e\n    {% for obj in object_list %}\n        \u003cli\u003e{{ obj.name }} - {{ obj.age }}\u003c/li\u003e\n    {% endfor %}\n    \u003c/ul\u003e\n\n**Sample requests**\n\n- GET /persons/\n- GET /persons/?profile_type=free\u0026gender=male\n- GET /persons/?profile_type=free\u0026gender=female\n- GET /persons/?profile_type=member\u0026gender=female\n- GET /persons/?ten_fingers=yes\n\nDevelopment\n===========\nTesting\n-------\nTo run tests in your working environment type:\n\n.. code-block:: sh\n\n    pytest -vrx\n\nTo test with all supported Python versions type:\n\n.. code-block:: sh\n\n    tox\n\nRunning MongoDB\n---------------\nThe easiest way is to run it via Docker:\n\n.. code-block:: sh\n\n    docker pull mongo:latest\n    docker run -p 27017:27017 mongo:latest\n\nWriting documentation\n---------------------\nKeep the following hierarchy.\n\n.. code-block:: text\n\n    =====\n    title\n    =====\n\n    header\n    ======\n\n    sub-header\n    ----------\n\n    sub-sub-header\n    ~~~~~~~~~~~~~~\n\n    sub-sub-sub-header\n    ^^^^^^^^^^^^^^^^^^\n\n    sub-sub-sub-sub-header\n    ++++++++++++++++++++++\n\n    sub-sub-sub-sub-sub-header\n    **************************\n\nLicense\n=======\nGPL-2.0-only OR LGPL-2.1-or-later\n\nSupport\n=======\nFor any security issues contact me at the e-mail given in the `Author`_ section.\n\nFor overall issues, go to `GitHub \u003chttps://github.com/barseghyanartur/django-mongoengine-filter/issues\u003e`_.\n\nAuthor\n======\nArtur Barseghyan \u003cartur.barseghyan@gmail.com\u003e\n\n.. _`mongoengine querysets`: http://mongoengine-odm.readthedocs.org/apireference.html#module-mongoengine.queryset\n.. _`read the docs`: https://django-mongoengine-filter.readthedocs.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarseghyanartur%2Fdjango-mongoengine-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarseghyanartur%2Fdjango-mongoengine-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarseghyanartur%2Fdjango-mongoengine-filter/lists"}