在Django中对CheckboxSelectMultiple(两个模型)选项进行分组

时间:2016-02-10 12:56:02

标签: django django-models django-forms

在Django中对CheckboxSelectMultiple选项进行分组 models.py:

class TestSuite(models.Model):
     test_suit = models.CharField(max_length=30)

class TestCase(models.Model):
     test_case= models.CharField(max_length=30)
     test_suit= models.ForeignKey(TestSuite)

我尝试了修复

Grouping CheckboxSelectMultiple Options in Django

我想在Django的管理界面中完成的是使用小部件CheckboxSelectMultiple呈现Category,但是按类别以SuperCategory分组,如下所示:

类别:

[] TestSuit1: <- Item of TestSuit
[ ] Test_case1 <- Item of TestCase
[ ] Test_case2 <- Item of TestCase
[ ] ...

[] TestSuit2: <- Another item of TestSuit
[ ] Test_case3
[ ] Test_case4
[ ] ...

0 个答案:

没有答案