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_linksis 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_detailsandis_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_formattersentries 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:
- Target view has
can_editand is accessible: link toedit_view. - Otherwise, target view has
can_view_detailsand is accessible: link todetails_view. - 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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flask_admin_autolinks-0.1.0.tar.gz | 5.8 kB | Without provenance | Details for flask_admin_autolinks-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flask_admin_autolinks-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for flask_admin_autolinks-0.1.0-py3-none-any.whl |
Total release size: 10.5 kB
Release files / flask_admin_autolinks-0.1.0.tar.gz
| Download URL | flask_admin_autolinks-0.1.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aef4e23dd784879d09db4bfeb1600bdbc6ab0b62f1fb5e923791ebb8da0536c8
|
|
BLAKE2b-256 checksum How to use checksums |
446918463599cd0c47010eb14fb136674a83a0467d546bcdc438b946e021d9e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.1 CPython/3.10.6 Linux/6.8.0-149-generic
|
Release files / flask_admin_autolinks-0.1.0-py3-none-any.whl
| Download URL | flask_admin_autolinks-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9200d5712f62ca97eeb6394e2e1acd6fb5ec02e06dd2aa39db95f207b6d425b0
|
|
BLAKE2b-256 checksum How to use checksums |
48904657d8b8a90034ad348e05610a4e5c010c3bffb73cb5791c600e351de61d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.1 CPython/3.10.6 Linux/6.8.0-149-generic
|
Security for flask-admin-autolinks 0.1.0
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.