如何在Django中给列列表change_list一个CSS类 [英] How to give a column in the Django admin change_list a CSS class

查看:227
本文介绍了如何在Django中给列列表change_list一个CSS类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改Django管理员列表显示中的列宽。

I'd like to change the column widths in the list display of the Django admin.

是否可能以某种方式向列添加CSS类名?
我最好不要覆盖整个模板来完成这个。

Is it possible somehow to add a CSS classname to a column? I'd preferably not overwrite the entire template to accomplish this.

推荐答案

在Django中= 1.6,CSS类包含在list_display输出中:

In Django >= 1.6, CSS classes are included with list_display output:

list_display 中的字段名称也将显示为CSS类HTML输出,每个< th> 元素的形式为 column-< field_name> 用于在CSS文件中设置列宽。

"The field names in list_display will also appear as CSS classes in the HTML output, in the form of column-<field_name> on each <th> element. This can be used to set column widths in a CSS file."

这篇关于如何在Django中给列列表change_list一个CSS类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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