Skip to main content

Inlines for sqladmin

Project description

sqladmin-inline

SQLAdmin Inline is an extension for sqladmin that brings Django-style inline editing to your SQLAlchemy models. It allows you to manage related records (one-to-many) directly within the parent model's form.

Coverage Status Coverage Status Coverage Status

Features

  • Django-style Inlines: Add, edit, and remove related records without leaving the main form.
  • Async & Sync Support: Fully compatible with both asynchronous and synchronous SQLAlchemy sessions.
  • Built-in Search & Pagination: Manage large numbers of child records with AJAX-powered search.
  • Flexible Layouts: Supports modal-based editing and different positions (center or sidebar).

Installation

pip install sqladmin-inline

Full Example

Based on the provided demo.py, here is how you can set up a Post with inline Tags and Comments:

from sqladmin import Admin
from sqladmin_inline import InlineModelAdmin, ModelViewWithInlines, setup_inline_routes

# 1. Define the Inline configuration
class TagInline(InlineModelAdmin, model=Tag):
    inline_label = "Tags"
    icon = "fas fa-tag"
    column_list = [Tag.name]
    column_searchable_list = [Tag.name]
    page_size = 5

class CommentInline(InlineModelAdmin, model=Comment):
    inline_label = "Comments"
    icon = "fa fa-comments"
    layout = "center" # Displays below the main form
    column_list = [Comment.body, Comment.author]
    form_columns = [Comment.body, Comment.author]

# 2. Use ModelViewWithInlines for the parent model
class PostAdmin(ModelViewWithInlines, model=Post):
    name_plural = "Posts"
    icon = "fa-solid fa-newspaper"
    inlines = [TagInline, CommentInline]

# 3. Initialize and register
app = FastAPI()
admin = Admin(app, engine, session_maker=session_mk)

# This step is CRITICAL to register AJAX routes and templates
setup_inline_routes(admin)

admin.add_view(PostAdmin)

Configuration Reference

InlineModelAdmin Attributes

  • model: The SQLAlchemy model class (required).
  • fk_attr: Explicit foreign key attribute name (auto-detected if omitted).
  • column_list: Columns to display in the inline table.
  • column_searchable_list: Columns to include in the AJAX search.
  • layout: "center" (below form) or "sidebar" (right side).
  • can_create, can_edit, can_delete: Permissions for the inline records.

Requirements

  • SQLAdmin >= 0.16.0
  • SQLAlchemy >= 2.0.0
  • Starlette / FastAPI

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

sqladmin_inline-0.0.3.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

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

sqladmin_inline-0.0.3-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file sqladmin_inline-0.0.3.tar.gz.

File metadata

  • Download URL: sqladmin_inline-0.0.3.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sqladmin_inline-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0d3786801ec9895e0268329d96f8ebbd2a79898317d3919e1605fbdc41c13e4f
MD5 466a7f472f5fe3fbe72532cf5b282665
BLAKE2b-256 36131d4601b4ffe282f0b8fa6420b84069d2725ecbf5bb5d2d2fef0c3647f8b6

See more details on using hashes here.

File details

Details for the file sqladmin_inline-0.0.3-py3-none-any.whl.

File metadata

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

File hashes

Hashes for sqladmin_inline-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1c38ea16edf16765af964b1dbce2f09098afaaca992340c9539a737cbfec2e33
MD5 b2daab7af48233fce9c3bd513a464afc
BLAKE2b-256 d5e598b9bd3cc782cdfd5fd983d3cbd47694132f4fef526275ac377b6ad9374f

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