Skip to main content

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.firstname for JSON)
  • Search indexing: Normalized values (NFKD, lowercase) concatenated with _ for startswith/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-only
  • blank=True, null=True: Optional (empty if all source fields are empty)
  • db_index=True: Indexed for search queries
  • unique=False: Homonyms allowed by default

Development

./service.py dev install-dev
./service.py dev test

License

MIT

Metadata

Release files for django-searchfield 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-searchfield 0.1.1
File Size Uploaded Provenance
django_searchfield-0.1.1.tar.gz 5.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-searchfield 0.1.1
File Interpreter ABI Platform
django_searchfield-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / django_searchfield-0.1.1.tar.gz

Download URL django_searchfield-0.1.1.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e29c222a7aebae21bfbff33dd10448ba6362ac3daebfa5d378b7ef68ae67c940
BLAKE2b-256 checksum
How to use checksums
5c7d2279aa90aff8a52d06d97938eee0126dac29f2ea6a7214271766be0c8e90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 2, 2026.

Transparency log

Release files / django_searchfield-0.1.1-py3-none-any.whl

Download URL django_searchfield-0.1.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d379067cc97d185828a7aa0b56d14dcbbafaea14425538e009d1db0035010ae
BLAKE2b-256 checksum
How to use checksums
c6148dccc842422d61c56671349ccc0aed9d55b39d061c2ecc89d7f752624757
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 2, 2026.

Transparency log

Security for django-searchfield 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_searchfield-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page