Skip to main content

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>"]
```

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

django-dynamic-finder-0.2.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file django-dynamic-finder-0.2.tar.gz.

File metadata

File hashes

Hashes for django-dynamic-finder-0.2.tar.gz
Algorithm Hash digest
SHA256 9d3580bd3bd300b612795ee0d3763c0be6782d25592f782609ccb42abc455487
MD5 0cfa5d68ff755b501b502e9298c86d7c
BLAKE2b-256 d2afdd494bee1f527bfd72fc61ab8cc0acf3d0c206de38b6aa7fe482ee9a13ec

See more details on using hashes here.

Supported by

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