model类如下,我在class Meta中设置了ordering = ['-date_create'],即模型对象返回的记录结果集是按照这个字段排序的。
class SystemUserPushHistory(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
host_name = models.CharField(max_length=128, null=False)
system_username = models.CharField(max_length=128, null=False)
method = models.CharField(max_length=32, null=False)
is_success = models.BooleanField(default=False)
date_create = models.DateTimeField(auto_now_add=True, editable=False)
message = models.CharField(max_length=4096, null=True)
class Meta:
db_table = "assets_systemuser_push_history"
ordering = ['-date_create']
def __str__(self):
ret = self.system_username + " => " + self.host_name
return ret
当业务有