我有django模型
class TestResult(models.Model):
chemical_name = char(50)
value =char(50)
unit = choices(UNIT_CHOICES)
method = choices(METHOD_CHOICES)
CSUSNormal = char(50)
CSUSCaution = char(50)
在管理页面中,此模型包含180条记录。现在我想通过创建字段order_num来应用这些记录的排序。如何根据每个字段的order_num设置排序?
我的管理页面我希望根据order_num字段查看所有记录。我怎样才能做到这一点?
答案 0 :(得分:3)
答案 1 :(得分:3)
class TestResult(models.Model): chemical_name = models.CharField(max_length=50) value =models.CharField(max_length=50) unit = models.CharField(choices=UNIT_CHOICES) method = models.CharField(METHOD_CHOICES) CSUSNormal = models.CharField(max_length=50) CSUSCaution = models.CharField(max_length=50) order_num=models.IntegerField() class Meta: ordering=" order_num"