Allow .warning and .error classes on more attributes in base.py
|Reported by:||Daniele Procida||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
class Person(models.Model): ... def colored_name(self): return '<span style="color: #%s;">%s %s</span>' % (self.color_code, self.first_name, self.last_name) colored_name.allow_tags = True class PersonAdmin(admin.ModelAdmin): list_display = ('first_name', 'last_name', 'colored_name')
This sort of thing could be really useful for reporting potential problems in the admin, both in list views and with readonly_fields, if it were possible to use classes that already exist in base.css for errors and warnings: https://github.com/django/django/blob/master/django/contrib/admin/static/admin/css/base.css#L524 for some other HTML attributes as well (<span> for example).
At present the Django admin does very well at informing the user of errors when something is saved in the admin. With a bit of effort it's quite easy to provide warnings too.
Being able to make use of classes for warnings and errors would make it easier to give information to the user about problematic conditions that already exist through the standard Django admin.
Does this seem like a good idea?