Django field that combines multiple fields into a search-indexed concatenated value
Project description
django-searchfield
Django field that concatenates multiple fields into a search-indexed string.
Purpose
Create a full-text search field by combining multiple model fields. Values are concatenated with _ by default for simple startswith / icontains queries.
Installation
pip install django-searchfield
Quick Start
Using SearchField directly
from django.db import models
from searchfield import SearchField
class Product(models.Model):
name = models.CharField(max_length=100)
code = models.IntegerField()
created_date = models.DateField()
search = SearchField(source_fields=["name", "code", "created_date"])
Using the decorator
from django.db import models
from searchfield import add_searchfield
@add_searchfield(search=["title", "category"])
class Article(models.Model):
title = models.CharField(max_length=200)
category = models.CharField(max_length=50)
content = models.TextField()
Path resolution (relations, JSON)
class Creditor(models.Model):
contact = models.ForeignKey(Contact, ...)
contact_data = models.JSONField() # {"firstname": "...", "lastname": "..."}
search = SearchField(source_fields=[
"name",
"contact.lastname", # relation
"contact_data.firstname", # JSON keys
])
Features
- Automatic generation: Values are generated automatically before saving
- Path resolution: Source paths support dotted notation (
name,contact.lastname,contact_data.firstnamefor JSON) - Search indexing: Normalized values (NFKD, lowercase) concatenated with
_forstartswith/icontains - Duplicate removal: Duplicate values from source fields are removed before concatenation
- Type formatting: Automatically formats dates, numbers, booleans
- Read-only: Field is editable=False
- db_index=True: Indexed for search performance
- unique=False: Not unique by default (allows homonyms); pass unique=True to enforce
Field Properties
editable=False: Read-onlyblank=True,null=True: Optional (empty if all source fields are empty)db_index=True: Indexed for search queriesunique=False: Homonyms allowed by default
Development
./service.py dev install-dev
./service.py dev test
License
MIT
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_searchfield-0.1.1.tar.gz.
File metadata
- Download URL: django_searchfield-0.1.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e29c222a7aebae21bfbff33dd10448ba6362ac3daebfa5d378b7ef68ae67c940
|
|
| MD5 |
d676c350f0b08fd59016b561d3c17dec
|
|
| BLAKE2b-256 |
5c7d2279aa90aff8a52d06d97938eee0126dac29f2ea6a7214271766be0c8e90
|
Provenance
The following attestation bundles were made for django_searchfield-0.1.1.tar.gz:
Publisher:
release.yml on octolo/django-searchfield
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_searchfield-0.1.1.tar.gz -
Subject digest:
e29c222a7aebae21bfbff33dd10448ba6362ac3daebfa5d378b7ef68ae67c940 - Sigstore transparency entry: 1702166776
- Sigstore integration time:
-
Permalink:
octolo/django-searchfield@1774498f9455664e07adfdd866b934fe7f4cdcc7 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/octolo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1774498f9455664e07adfdd866b934fe7f4cdcc7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_searchfield-0.1.1-py3-none-any.whl.
File metadata
- Download URL: django_searchfield-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d379067cc97d185828a7aa0b56d14dcbbafaea14425538e009d1db0035010ae
|
|
| MD5 |
e7fdfbee2ace4166f607b0fb45c54cb3
|
|
| BLAKE2b-256 |
c6148dccc842422d61c56671349ccc0aed9d55b39d061c2ecc89d7f752624757
|
Provenance
The following attestation bundles were made for django_searchfield-0.1.1-py3-none-any.whl:
Publisher:
release.yml on octolo/django-searchfield
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_searchfield-0.1.1-py3-none-any.whl -
Subject digest:
7d379067cc97d185828a7aa0b56d14dcbbafaea14425538e009d1db0035010ae - Sigstore transparency entry: 1702166802
- Sigstore integration time:
-
Permalink:
octolo/django-searchfield@1774498f9455664e07adfdd866b934fe7f4cdcc7 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/octolo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1774498f9455664e07adfdd866b934fe7f4cdcc7 -
Trigger Event:
push
-
Statement type: