﻿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
31427	Better support for __html__ in django admin	Olivier Dalang	nobody	"Django supports custom html representation for objects using the __html__ method (see https://code.djangoproject.com/ticket/7261)

This is supposedly used when trying to display to object as html : if the object provides an __html__ representation, this is used instead of an html-escaped version of __str__. This is implemented in `django.utils.html.conditional_escape`, used in turn by `format_html` (and similar).

This feature is really nice. It allows for instance to add colors or icons to the instances representation very consistently., which in some cases can really help in terms of UX (e.g. color for instance's state).

Unfortunately, this is is only very partially supported in Django admin, where most of the time, the __str__ representation is used instead.

Currently, the only place where I could see the __html__ used is in the confirmation message after changing an object (""The object “XYZ” was changed successfully.).

The __html__ method is not used in :
- the default representation of the changelist (when list_display is not set)
- the breadcrumbs
- the filters of the changelist
- the select with autocomplete (despite select2 supporting html)
- etc...

I suggest changing this wherever possible in Django admin. It shouldn't be too big of a change. It's probably mostly replacing str(obj) by conditional_escape(obj) wherever HTML is admissible.

Long live Django & Django admin :-)"	Uncategorized	new	contrib.admin	3.0	Normal				Unreviewed	0	0	0	0	0	1
