Skip to main content

Django Admin Anchors

PyPI PyPI - Python Version PyPI - Django Version Codecov License

Turn Django admin list display items into clickable links to related objects using decorators.

Clicking admin anchors will redirect to a filtered changelist view showing the related objects. This allows you to get a quick overview and run actions on the filtered objects.

Installation

pip install django-admin-anchors

Usage

Take a look at the tests/project directory to see a runnable example project.

Add links to the object list page

Object list page (light mode) Object list page (dark mode)

from django.contrib import admin
from admin_anchors import admin_anchor
from yourapp.models import Team


@admin.register(Team)
class TeamAdmin(admin.ModelAdmin):
    list_display = ["__str__", "captain_link", "captains_profile_link", "members_link"]

    @admin_anchor("captain")
    def captain_link(self, instance):
        return str(instance.captain)

    @admin_anchor("captain.profile")
    def captains_profile_link(self, instance):
        return "Captains profile"

    @admin_anchor("members")
    def members_link(self, instance):
        return f"{instance.members.count()} members"

Add links to the object update page

Object change page (light mode) Object change page (dark mode)

from django.contrib import admin
from admin_anchors import admin_anchor
from yourapp.models import Player


@admin.register(Player)
class PlayerAdmin(admin.ModelAdmin):
    readonly_fields = ["profile_link"]

    @admin_anchor("profile")
    def profile_link(self, instance):
        return "Profile"

Example project

Take a look at our Django example project under tests/project. You can run it by executing these commands:

  1. uv sync
  2. uv run tests/project/manage.py migrate
  3. uv run tests/project/manage.py createsuperuser
  4. uv run tests/project/manage.py runserver

Release files for django-admin-anchors 4.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-admin-anchors 4.5.0
File Size Uploaded
django_admin_anchors-4.5.0.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-anchors 4.5.0
File Interpreter ABI Platform
django_admin_anchors-4.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.4 kB

Release files / django_admin_anchors-4.5.0.tar.gz

Download URL django_admin_anchors-4.5.0.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a6f933b0e601c7c5067d90a0c8e9d54c364a8d549fa2c012e0d8e049c5ea26e0
BLAKE2b-256 checksum
How to use checksums
6781e6f5f060d9251d6dd5a98be2a5e1afc361290a6f6c7fe73090c23770c1ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / django_admin_anchors-4.5.0-py3-none-any.whl

Download URL django_admin_anchors-4.5.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f812a25c2db375b25eb2c911f8ad90d6a6e2dcea5f592fe806f4d6543de60af7
BLAKE2b-256 checksum
How to use checksums
3eb7bfdbd98c69415717f44090a1d9c465defa3c3bee49abafa64163a4538aa8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

4.5.0 This release

2 release files

4.4.0

2 release files

4.3.0

2 release files

4.2.0

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.0.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

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