Skip to content

feat: support additional template loaders and static packages (#743)#770

Open
SHYXIN wants to merge 3 commits into
jowilf:mainfrom
SHYXIN:feat/additional-template-static-loaders
Open

feat: support additional template loaders and static packages (#743)#770
SHYXIN wants to merge 3 commits into
jowilf:mainfrom
SHYXIN:feat/additional-template-static-loaders

Conversation

@SHYXIN
Copy link
Copy Markdown

@SHYXIN SHYXIN commented May 17, 2026

Summary

Allows third-party packages and custom fields to register their own templates and static files with the admin interface.

Changes

  • starlette_admin/base.py — Added two new BaseAdmin parameters:
    • additional_template_loaders: Sequence[BaseLoader] — Extra Jinja2 template loaders
    • additional_static_packages: Sequence[str] — Extra Python packages for static files
  • _setup_templates() — Includes additional loaders in the ChoiceLoader
  • init_routes() — Includes additional packages in StaticFiles

Usage

from jinja2 import PackageLoader
from starlette_admin.contrib.sqla import Admin

admin = Admin(
    engine,
    additional_template_loaders=[PackageLoader("my_package", "templates")],
    additional_static_packages=["my_package"],
)

Testing

  • All 14 views tests pass
  • Manual verification with FileSystemLoader and empty static packages

Additional

Includes chore commit to fix pyproject.toml pytest config conflict.

SHYXIN and others added 3 commits May 17, 2026 17:10
…#743)

Allows third-party packages and custom fields to register their own
templates and static files with the admin interface.

New BaseAdmin parameters:
- additional_template_loaders: Sequence[BaseLoader] - Extra Jinja2 loaders
- additional_static_packages: Sequence[str] - Extra packages for static files

Usage:
    admin = Admin(
        engine,
        additional_template_loaders=[PackageLoader("my_pkg", "templates")],
        additional_static_packages=["my_pkg"],
    )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant