更新时间:2022-01-20 05:14:54
使用带有反向过滤器(-)的order_by,然后使用[1]抓取第二个对象.
Use order_by with a reverse filter (-) and then grab the second object by using [1].
class Salaries(models.Model):
employee_name = models.CharField(max_length=255)
salary = models.IntegerField()
q = Salaries.objects.all().order_by('-salary')
second_highest_paid_name = q[1].employee_name