﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32804	Add 'link' attribute to admin display function to enable custom link	Skrattoune	nobody	"Hi, The new admin.display decorator is great for decreasing the burden for declaring custom admin pages.

What would be even greater for my personal django usage, would be to add directly from the display decorator the possibility to associate a custom link to the displayed attribute.

For instance, instead of having to declare in the AdminModel:
{{{
@admin.display(ordering='-nb_variants', description='nb_variants')
def _nb_variants(self, obj):
    # adding a link to open a new tab with the result
    return format_html(f'<a href=""/admin/puzzles/puzzle/?uncolored_puzzle_id={obj.uncolored_puzzle_id}"" target=""_blank"">{obj.nb_variants}</a>')
}}}

to enable declaring directly inside the model at the property or method level:

{{{

def href_to_variants(self):
    return f""/admin/puzzles/puzzle/?uncolored_puzzle_id={self.uncolored_puzzle_id}""

@cached_property
@admin.display(
    link='href_to_variants',
    target_blank=True,
    )
def nb_variants(self):
    return self.variants.count()

}}}
"	New feature	closed	contrib.admin	3.2	Normal	wontfix	admin, hyperlink, decorator, display	pope1ni	Unreviewed	0	0	0	0	0	0
