Skip to content

Latest commit

 

History

History
64 lines (46 loc) · 1.95 KB

File metadata and controls

64 lines (46 loc) · 1.95 KB

Wagtail-style admin

Enable the built-in admin with session login:

from oxyde_config import DATABASES
from ragtail.fastapi import create_app
from ragtail.auth import ensure_superuser

app = create_app(
    **DATABASES,
    mount_ragtail_admin=True,
    secret_key="replace-me",
)

# once, e.g. in startup:
await ensure_superuser(username="admin", password="admin")

For production, prefer make createsuperuser or ragtail-createsuperuser instead of hard-coded credentials.

Features

  • Sign-in screen styled like Wagtail
  • Sidebar navigation (Dashboard, Pages, Menus, Locales)
  • Page explorer with tree + child listing
  • Page editor (title, slug, SEO, publish settings)
  • Locale management (add a second language, creates root page)
  • Menu builder (create menus and add page/URL items)
  • Create / edit / delete pages

Rich text body on ContentPage

Register a page model with a body field. Fields named body automatically use the TipTap rich text widget in the admin:

from oxyde import Field
from ragtail import Page, register_page_model

@register_page_model
class ContentPage(Page):
    body: str | None = Field(default=None, db_type="TEXT")

See examples/demo/pages.py.

StreamField on page models

Page models can declare a StreamField for flexible block-based content (Markdown, HTML, images, button/link structs, and custom templates). The admin provides add / reorder / remove controls and a TipTap + HTML toggle for HTML blocks.

from ragtail.streamfield import HtmlTextBlock, MarkdownTextBlock, StreamField, StreamValue

@register_page_model
class ContentPage(Page):
    content: StreamValue | None = StreamField(
        [MarkdownTextBlock(), HtmlTextBlock()],
        default=None,
    )

See StreamField for built-in blocks, StructBlock, custom block subclasses, and rendering.

The legacy generic oxyde-admin CRUD remains available via mount_admin=True on create_app or the [admin] extra.