A Django version of the Rails Dynamic Finder, using Django Managers.
Project description
Django Dynamic Finder
=====================
A Django version of the Rails Dynamic Finder, using Django Managers.
# Install
```sh
$ pip install django-dynamic-finder
```
# Setup
```python
# settings.py
INSTALLED_APPS = (
...
'django_dynamic_finder',
...
)
```
```python
# project/app/models.py
from django.db import models
from django_dynamic_finder import DynamicFinderManager
class Model(models.Model):
name = models.CharField(max_length=50)
objects = DynamicFinderManager()
```
# Usage
```python
>>> Model.objects.get_by_name('Jonh')
# >>> Model.objects.get(name='Jonh')
<Model: #1 - Jonh>
>>> Model.objects.filter_by_name('Jonh')
# >>> Model.objects.filter(name='Jonh')
["<Model: #1 - Jonh>"]
>>> Model.objects.exclude_by_name('Jonh')
# >>> Model.objects.exclude(name='Jonh')
["<Model: #2 - Alice>", "<Model: #3 - Bob>"]
>>> Model.objects.filter_by_name_or_name('Jonh', 'Alice')
# >>> Model.objects.filter(Q(name='Jonh') | Q(name='Alice'))
["<Model: #1 - Jonh>", "<Model: #2 - Alice>"]
>>> Model.objects.exclude_by_name_or_id('Jonh', 3)
# >>> Model.objects.exclude(Q(name='Jonh') | Q(id=3))
["<Model: #2 - Alice>"]
>>> Model.objects.filter_by_name_or_id_or_name('Jonh', 3, 'Alice')
# >>> Model.objects.filter(Q(name='Jonh') | Q(id=3) | Q(name='Alice'))
["<Model: #1 - Jonh>", "<Model: #2 - Alice>", "<Model: #3 - Bob>"]
```
=====================
A Django version of the Rails Dynamic Finder, using Django Managers.
# Install
```sh
$ pip install django-dynamic-finder
```
# Setup
```python
# settings.py
INSTALLED_APPS = (
...
'django_dynamic_finder',
...
)
```
```python
# project/app/models.py
from django.db import models
from django_dynamic_finder import DynamicFinderManager
class Model(models.Model):
name = models.CharField(max_length=50)
objects = DynamicFinderManager()
```
# Usage
```python
>>> Model.objects.get_by_name('Jonh')
# >>> Model.objects.get(name='Jonh')
<Model: #1 - Jonh>
>>> Model.objects.filter_by_name('Jonh')
# >>> Model.objects.filter(name='Jonh')
["<Model: #1 - Jonh>"]
>>> Model.objects.exclude_by_name('Jonh')
# >>> Model.objects.exclude(name='Jonh')
["<Model: #2 - Alice>", "<Model: #3 - Bob>"]
>>> Model.objects.filter_by_name_or_name('Jonh', 'Alice')
# >>> Model.objects.filter(Q(name='Jonh') | Q(name='Alice'))
["<Model: #1 - Jonh>", "<Model: #2 - Alice>"]
>>> Model.objects.exclude_by_name_or_id('Jonh', 3)
# >>> Model.objects.exclude(Q(name='Jonh') | Q(id=3))
["<Model: #2 - Alice>"]
>>> Model.objects.filter_by_name_or_id_or_name('Jonh', 3, 'Alice')
# >>> Model.objects.filter(Q(name='Jonh') | Q(id=3) | Q(name='Alice'))
["<Model: #1 - Jonh>", "<Model: #2 - Alice>", "<Model: #3 - Bob>"]
```
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
File details
Details for the file django-dynamic-finder-0.2.tar.gz
.
File metadata
- Download URL: django-dynamic-finder-0.2.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d3580bd3bd300b612795ee0d3763c0be6782d25592f782609ccb42abc455487 |
|
MD5 | 0cfa5d68ff755b501b502e9298c86d7c |
|
BLAKE2b-256 | d2afdd494bee1f527bfd72fc61ab8cc0acf3d0c206de38b6aa7fe482ee9a13ec |