TechServ in-house ORM model attribute filtering
Project description
ts-django-filtering
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
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d57f24906b9fefc5c8f6c767e8015de797e744a7bcbf4cda4d05e4a277b5e95e
|
|
| MD5 |
b2e3802eb21174bd3781613866e86670
|
|
| BLAKE2b-256 |
190c404ef48ff0c628eed0620045d66183da9bcd4cd430592a2344caa3e3cdec
|
File details
Details for the file ts_django_filtering-1.1.0-py3-none-any.whl.
File metadata
- Download URL: ts_django_filtering-1.1.0-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6249714b4fce81063c98349ce98f14b220df4ee2334acb7034f4373ec12a5068
|
|
| MD5 |
7dd600c8c80331ee72234c1e549005e9
|
|
| BLAKE2b-256 |
6ca05c823554a8b5d855dc6d300c289bbdc85da7d6a12f62bcf0e138f8511d9b
|