首页 > 解决方案 > 在 django 表中使用字段作为行

问题描述

我正在使用 django_tables2 库,但在文档中没有看到将字段用作行而不是列。

class PizzaTable(tables.Table):
    class Meta:
        model = PizzaInstance
        fields = ("pizza", "type", "size", "price")
        attrs = {"class": "mytable"}

试图在一行下显示两个实例,如下所示:

         small    large
cheese   $1       $2

instead of 
cheese small $1
cheese large $2

我可以在 django_tables2 库中使用比萨饼和类型作为行吗?

标签: django

解决方案


推荐阅读