Skip to main content

TechServ in-house ORM model attribute filtering

Project description

ts-django-filtering

PyPI - Version

In-house solution for kwarg and attribute access based filtering of Django ORM models.

Install

$ pip install ts-django-filtering

Usage

from my_app.models import Person
from django_filtering import Filter, FilterSet

my_filters = [
    {
        "path": "job.name",
        "operator": "iexact",
        "value": "Engineer"
    },
    {
        "path": "job.requirement.name",
        "operator": "icontains",
        "value": "Plumbing"
    },
]

filters = Filter.from_list(my_filters)
print(Filter.merge_to_dict(*filters))
# {'job__name__iexact': 'Engineer', 'job__requirement__name__icontains': 'Plumbing'}

print(FilterSet(filters=filters).filter(Person))
# <QuerySet [<Person: Person object (1)>]>

### or for instance filtering

filters = Filter.from_list([
    {
        "path": "name",
        "operator": "exact",
        "value": "Joe"
    }
])

people = [
    Person(name="Jeff"),
    Person(name="John"),
    Person(name="Joe"),
]

FilterSet(filters=filters).filter(people)
# <List [<Person: Person object("Joe")>]>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ts_django_filtering-1.1.0.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ts_django_filtering-1.1.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file ts_django_filtering-1.1.0.tar.gz.

File metadata

  • Download URL: ts_django_filtering-1.1.0.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for ts_django_filtering-1.1.0.tar.gz
Algorithm Hash digest
SHA256 d57f24906b9fefc5c8f6c767e8015de797e744a7bcbf4cda4d05e4a277b5e95e
MD5 b2e3802eb21174bd3781613866e86670
BLAKE2b-256 190c404ef48ff0c628eed0620045d66183da9bcd4cd430592a2344caa3e3cdec

See more details on using hashes here.

File details

Details for the file ts_django_filtering-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ts_django_filtering-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6249714b4fce81063c98349ce98f14b220df4ee2334acb7034f4373ec12a5068
MD5 7dd600c8c80331ee72234c1e549005e9
BLAKE2b-256 6ca05c823554a8b5d855dc6d300c289bbdc85da7d6a12f62bcf0e138f8511d9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page