更改 Django 管理列表中的行颜色 [英] Change row colour in Django Admin List

查看:21
本文介绍了更改 Django 管理列表中的行颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据模型中名为状态的字段在 Django 管理页面 (change_list.html) 中突出显示行(设置背景颜色).这样做的最佳方法是什么?

I want to highlight rows (set the backgorund colour) in the Django Admin page (change_list.html) based on a field in the model called status. What is the best way to do this?

我有 3 个状态.打开,活动,关闭.我希望打开的行为绿色,活动的行为橙色,关闭的行为红色.

I have 3 statuses. Open, Active, Closed. I'd like rows with open to be green, active to be orange and closed to be red.

我找到了有关更改模板的文档,但不确定如何检查状态以进行着色行.

I've found documentation about changing the templates so but not sure how to check the status to colour the row.

推荐答案

查看 django-liststyle,正是您所追求的.

Check out django-liststyle, exactly what you're after.

这篇关于更改 Django 管理列表中的行颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆