一般这个颜色列表是放在models.py里
charge_type_class_mapping = {
1: "success",
2: "danger",
3: "default",
4: "info",
5: "primary",
}
color.py
from django.template import Library
from web import models
register = Library()
@register.filter()
def type_color(charge_type_num):
return models.TransactionRecord.charge_type_class_mapping[charge_type_num]
标签:自定义,models,django,color,charge,type,模板 From: https://www.cnblogs.com/superip/p/17276011.html