Simple but powerful search/filter functionality for Django projects
Project description
django-find
Summary
django-find is a Django app that makes it easy to add complex search/filter functionality for the models in your project. It supports two different ways to search your Django models: Query-based, or JSON-based.
django-find is not a full text search engine, it searches the fields of your models. In other words, it filters on your models and provides tabular data as a result.
Features
Query-based search
By query-based, we mean that you can use statements like these to search your models:
author:"robert frost" and (title:road or chapter:2)
Add a search field to your template using a single tag
{% load find_tags %}
{% find object_list %}
{% for obj in object_list %}
{{ obj.name }}
{% endfor %}
(object_list is a queryset that is passed to the template)
Query in your code
Just add the Searchable mixin:
from django_find import Searchable
class Author(models.Model, Searchable):
name = models.CharField("Author Name", max_length=10)
...
And you are good to go:
# Query-based search returns a standard Django QuerySet that you
# can .filter() and work with as usual.
query = Book.by_query('author:"robert frost" and title:"the road"')
# You can also get a Django Q object for the statements.
q_obj = Book.q_from_query('author:"robert frost" and title:"the road"')
Query using JSON
To make it easy to do complex searches spanning multiple models, JSON-based query method is provided. It allows your to make custom searches like these:
For this, a JSON-based search functionality is provided:
{
"Author":{"name":[[["equals","test"]]]},
"Book": {"title":[[["notcontains","c"]]]},
"Chapter": {"content":[[["startswith","The "]]]}
}
django-find is smart in figuring out how to join those models together and return a useful result. In your code, you can load the JSON and get back the search result:
# JSON-based search exhausts what Django's ORM can do, so it does
# not return a Django QuerySet, but a row-based PaginatedRawQuerySet:
query, field_list = Book.by_json_raw('''{
"Chapter": {"title":[[["contains","foo"]]]}
}''')
print('|'.join(field_list))
for row in query:
print('|'.join(row))
Documentation
Full documentation, including installation instructions, is here:
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
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 django_find-1.0.1.tar.gz.
File metadata
- Download URL: django_find-1.0.1.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a7131e700afac734da4b43da069a0bfcb16f5f2cbb3f006a768e62c6460c1d4
|
|
| MD5 |
ae215df0a0ccad6fee6bb048a2c1005d
|
|
| BLAKE2b-256 |
f7a2fb2034ec183129214ca06024268caa30b2d95abc35d138bc33c77f770b22
|
Provenance
The following attestation bundles were made for django_find-1.0.1.tar.gz:
Publisher:
publish.yml on knipknap/django-find
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_find-1.0.1.tar.gz -
Subject digest:
7a7131e700afac734da4b43da069a0bfcb16f5f2cbb3f006a768e62c6460c1d4 - Sigstore transparency entry: 1037929793
- Sigstore integration time:
-
Permalink:
knipknap/django-find@ce53683e576a7f3408bb9c2b963082c76ebb8ba2 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/knipknap
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ce53683e576a7f3408bb9c2b963082c76ebb8ba2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_find-1.0.1-py3-none-any.whl.
File metadata
- Download URL: django_find-1.0.1-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c40deaff9820ac81eea72ac251afa9594fa7ee72d246cf710aa972531ef89c4
|
|
| MD5 |
71d8694a62fd4b8d12bae0d052cbd9c2
|
|
| BLAKE2b-256 |
0a11f65fed77180072b9768a977242b499516d79d1a073afbc31084738f89c3e
|
Provenance
The following attestation bundles were made for django_find-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on knipknap/django-find
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_find-1.0.1-py3-none-any.whl -
Subject digest:
2c40deaff9820ac81eea72ac251afa9594fa7ee72d246cf710aa972531ef89c4 - Sigstore transparency entry: 1037929860
- Sigstore integration time:
-
Permalink:
knipknap/django-find@ce53683e576a7f3408bb9c2b963082c76ebb8ba2 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/knipknap
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ce53683e576a7f3408bb9c2b963082c76ebb8ba2 -
Trigger Event:
push
-
Statement type: