Skip to main content

Scolta AI Search for Django — zero-infrastructure AI search with Pagefind

Project description

scolta-django

Scolta AI Search for Django — zero-infrastructure AI-powered search with Pagefind. The Django adapter over the scolta Python binding.

Install & configure

# settings.py
INSTALLED_APPS = [..., "scolta_django"]

SCOLTA = {
    "ai_api_key": env("SCOLTA_API_KEY"),
    "ai_provider": "anthropic",
    "site_name": "My Site",
    "indexer": "auto",                 # pure-Python indexer (default)
    "models": ["blog.Post", "pages.Page"],   # models using SearchableMixin
    "output_dir": BASE_DIR / "static" / "scolta-pagefind",
    "state_dir": BASE_DIR / ".scolta-state",
    "auto_rebuild": True,              # debounced rebuild on model save/delete
    "auto_rebuild_delay": 300,
    "route_prefix": "api/scolta/v1",
}
# urls.py
urlpatterns = [..., path("", include("scolta_django.urls"))]

Make a model searchable:

from scolta_django.searchable import SearchableMixin

class Post(SearchableMixin, models.Model):
    title = models.CharField(max_length=200)
    body = models.TextField()
    # Override for HTML content / custom URLs:
    def to_searchable_content(self):
        from scolta.content import ContentItem
        return ContentItem(id=f"post-{self.pk}", title=self.title,
                           body_html=self.body, url=self.get_absolute_url(),
                           date=self.updated_at.strftime("%Y-%m-%d"))

Build the index and render the widget:

python manage.py scolta_build          # --force --incremental --resume --restart
{% load scolta %}{% scolta_search %}

Static assets

The browser runtime (scolta.js/css, the WASM scoring engine, the Pagefind runtime) is vendored inside the scolta package, where no default staticfiles finder looks. Add the bundled finder so collectstatic (and the dev server) serve it at the default asset_url (/static/scolta/):

STATICFILES_FINDERS = [
    "django.contrib.staticfiles.finders.FileSystemFinder",
    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
    "scolta_django.staticfiles.ScoltaAssetFinder",
]

Settings:

  • SCOLTA["asset_url"] (default /static/scolta/) — base URL the {% scolta_search %} tag uses for the CSS/JS/WASM tags. Point it elsewhere if you serve the bundle from a CDN or copy it yourself.
  • SCOLTA["amazee_access"] (optional) — callable (request) -> bool gating the Amazee.ai settings page and JSON endpoints. Default: active staff user.

Health endpoint

GET /api/scolta/v1/health always answers monitoring tools: anonymous requests get {"status": "ok"} (or "degraded"), HTTP 200. The full diagnostic payload (AI provider, configured flags, index state) requires an active staff user — the same bar as staff_member_required, without the login redirect that would break uptime monitors.

Wagtail

If Wagtail is installed, the optional scolta_django.wagtail module is loaded automatically (StreamField extraction, page-tree enumeration, admin panel). Indexing Wagtail pages is opt-in: set SCOLTA["wagtail"] = True to use the Wagtail content source, which indexes live public pages alongside the configured models. With the flag unset, only SCOLTA["models"] are indexed (the admin panel and signal wiring load either way).

Development

uv venv --python 3.12 && uv pip install -e ".[dev]"
uv run pytest

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

scolta_django-1.0.1.tar.gz (122.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scolta_django-1.0.1-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file scolta_django-1.0.1.tar.gz.

File metadata

  • Download URL: scolta_django-1.0.1.tar.gz
  • Upload date:
  • Size: 122.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for scolta_django-1.0.1.tar.gz
Algorithm Hash digest
SHA256 aaf04720ffa162aab756ccc3646a774296ab607b016604ba7ae364a551ecb1e1
MD5 527c55719bb6303de5ffadd8dc07fc01
BLAKE2b-256 fe7187321c0011e49001f53ccb238eef13d300e7e5f178725e793aa4ab6947be

See more details on using hashes here.

File details

Details for the file scolta_django-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: scolta_django-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for scolta_django-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aba8e58cac2dc4bba53384b4a5fa2d7e72b08613303a2e8584824758e680cb65
MD5 cfc5d7d5e20b271f38a4f33bd1610216
BLAKE2b-256 3c0deb143b9ea36657932ddbed1bc9d5febe75af6b0e0b74c1307f7a332d6dbf

See more details on using hashes here.

Supported by

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