Skip to main content

django-wagtail-ai-generation

A floating AI assistant for the Wagtail page editor — generate StreamField content with a live JSON schema, paste results from any LLM, or wire your own model for one-click Generate & apply.

Portable Django package · MIT · by Aymane Nahji

Python 3.11+ Django 5+ Wagtail 6+ License: MIT


Why this package

Editors stay inside Wagtail. The assistant inspects the page you are editing and every StreamField on that model, then builds prompts that match your block types — CharBlock, RichTextBlock, localized structs, images, Lucide icons, and more.

Mode Setup Best for
Copy & paste pip install + INSTALLED_APPS Teams using ChatGPT, Claude, or any external tool
In-app agent WAGTAIL_AI_GENERATION_LLM_ENABLED + your hook callables One-click generation inside the admin bubble

No page model name, no hard-coded body field, no LLM API keys in settings unless you opt in.


Quick start

pip install django-wagtail-ai-generation
INSTALLED_APPS = [
    # ...
    "wagtail",
    "wagtail_ai_generation",
]

Expose your stream fields with a normal FieldPanel. If the user can edit the page and the model has at least one StreamField, the bubble appears automatically — no extra panel required.

For tests or copy/paste-only deployments:

WAGTAIL_AI_GENERATION_LLM_ENABLED = False  # default

What you get

  • Floating assistant on page edit — schema-aware prompts and JSON apply in one place.
  • Per-block actions — AI edit and AI replace on each stream block (alongside your other block actions).
  • Live schema bundle — minimal shape examples derived from block types on the current page.
  • Image helpers — optional download of placeholder image URLs into Wagtail Image records (requires Pillow).
  • Translations — admin strings packaged for English, French, and Arabic.
  • Strict optional LLM wiring — when the agent is enabled, missing hooks fail fast at startup with actionable ImproperlyConfigured messages.

Pair with django-wagtail-icon-chooser so IconChooserBlock values appear as lucide_icon in generated JSON.


Optional in-app LLM

Enable only when you want a Generate and apply tab in the bubble:

WAGTAIL_AI_GENERATION_LLM_ENABLED = True

WAGTAIL_AI_GENERATION_LLM_HOOKS = {
    "agent_context": "myapp.llm.agent_context",
    "get_connection": "myapp.llm.get_connection",
    "run_completion": "myapp.llm.run_completion",
    "connection_not_found_exception": "myapp.llm.NoConnection",
    "admin_url_names": {
        "list": "myapp:connection_list",
        "create": "myapp:connection_create",
        "api": "myapp:connection_api",
        "setCurrentModel": "myapp:connection_set_model",
    },
    # "connection_summary": "myapp.llm.connection_summary",  # optional
}

Every hook must be set explicitly — there is no automatic coupling to a companion app. Reference callables you can delegate to: wagtail_ai_generation.llm_defaults.run_litellm_completion and .connection_summary.

Hook contract, settings tables, and schema notes: wagtail_ai_generation/README.md.


Requirements

Dependency Version
Python 3.11+
Django 5.0+
Wagtail 6.0+
Pillow 10.0+ (image URLs in AI JSON)

Admin API (staff + CSRF)

Method Path When
GET …/ai-generation/context/ Page has StreamFields
POST …/ai-generation/ Apply pasted JSON
POST …/ai-generation/run/ LLM_ENABLED and valid hooks

Paths are under your Wagtail admin URL prefix.


Develop & test

pip install -e ".[dev]"
PYTHONPATH=. DJANGO_SETTINGS_MODULE=tests_project.settings python -m django test wagtail_ai_generation

The bundled test project keeps WAGTAIL_AI_GENERATION_LLM_ENABLED = False so the suite runs without a connections backend.


Wagtail toolkit

Built to compose with the rest of the stack:

Package Role
django-wagtail-blocks-exchange Copy blocks across pages and StreamFields
django-wagtail-icon-chooser Lucide icon picker; AI schema type lucide_icon

License

MIT — see LICENSE.

Metadata

Release files for django-wagtail-ai-generation 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-wagtail-ai-generation 0.1.1
File Size Uploaded Provenance Actions
django_wagtail_ai_generation-0.1.1.tar.gz 107.2 kB Without provenance Details for django_wagtail_ai_generation-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-wagtail-ai-generation 0.1.1
File Interpreter ABI Platform Actions
django_wagtail_ai_generation-0.1.1-py3-none-any.whl Python 3 none any Details for django_wagtail_ai_generation-0.1.1-py3-none-any.whl

Total release size: 180.3 kB

Release files / django_wagtail_ai_generation-0.1.1.tar.gz

Download URL django_wagtail_ai_generation-0.1.1.tar.gz
Size 107.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7f7abed74bf38cb2097b23bc4f2c7e8b316a285df6a02d985dc0b21c9fc6e944
BLAKE2b-256 checksum
How to use checksums
d5f7d3b4e003a5bfede4c98123b7e606abd741a8dc32251b863f16e15b01d40a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

Download URL django_wagtail_ai_generation-0.1.1-py3-none-any.whl
Size 73.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1bf7223eb69a1c322d6d9df71dbd542db222efae9d6f75b2e09026cf6333f626
BLAKE2b-256 checksum
How to use checksums
bf40ef779ff127db2f7b17aee24c3d52d71e4642658534164478a0cb17b95912
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for django-wagtail-ai-generation 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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No 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