Skip to main content

flask-admin-autolinks

Automatic hyperlinks for relationship columns in Flask-Admin's SQLAlchemy list views.

By default, a relationship column renders as plain text (str() of the related object). With this mixin, each related object becomes a link to its own edit (or details) page in the admin.

Features

  • Opt-in per view. No effect unless column_relationship_links is set.
  • Resolves the target view from the registered views by model. No endpoint naming convention required.
  • Respects the target view's can_edit, can_view_details and is_accessible(). Falls back to plain text.
  • Eager-loads link targets through the view's _auto_joins, so the list page does not issue N+1 queries.
  • Explicit column_formatters entries always win.
  • Output is escaped.

Installation

uv add flask-admin-autolinks
# or
pip install flask-admin-autolinks

Requires Flask-Admin with SQLAlchemy support (flask-admin[sqlalchemy]). Supported versions are declared in pyproject.toml.

Usage

Place AutoLinksMixin before ModelView in the bases:

from flask_admin.contrib.sqla import ModelView
from flask_admin_autolinks import AutoLinksMixin


class OrderView(AutoLinksMixin, ModelView):
    column_list = ("id", "customer", "items")
    column_relationship_links = True

For project-wide use, define a shared base once:

class BaseView(AutoLinksMixin, ModelView):
    column_relationship_links = True

Only relationship columns listed in column_list are linked.

Configuration

column_relationship_links accepts:

Value Behavior
False (default) Disabled.
True Link every relationship column in column_list to the registered view for the related model.
dict[str, str] Same as True, with per-column overrides mapping a relationship name to a view endpoint.
class OrderView(AutoLinksMixin, ModelView):
    column_list = ("id", "customer", "items")
    column_relationship_links = {"customer": "client"}  # "client" is the target view's endpoint

An empty dict is falsy and leaves the feature disabled.

Behavior

For each related object, the link target is chosen in this order:

  1. Target view has can_edit and is accessible: link to edit_view.
  2. Otherwise, target view has can_view_details and is accessible: link to details_view.
  3. Otherwise: escaped plain text.

If no view is registered for the related model (or the override endpoint is not found), the cell renders as plain text. The list page is never broken by a missing target.

Collections render as comma-separated links. None renders as an empty cell.

A column that already has an entry in column_formatters is left untouched and is not eager-loaded by this package.

To Do

  • SQLAlchemy backend only (flask_admin.contrib.sqla), add others.

License

See LICENSE for MIT License.

IA

Documentation done with Claude.

Metadata

Release files for flask-admin-autolinks 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 flask-admin-autolinks 0.1.1
File Size Uploaded Provenance Actions
flask_admin_autolinks-0.1.1.tar.gz 5.9 kB Without provenance Details for flask_admin_autolinks-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flask-admin-autolinks 0.1.1
File Interpreter ABI Platform Actions
flask_admin_autolinks-0.1.1-py3-none-any.whl Python 3 none any Details for flask_admin_autolinks-0.1.1-py3-none-any.whl

Total release size: 10.6 kB

Security for flask-admin-autolinks 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