请帮我解决一个问题我尝试了很多,但遗憾的是找不到解决方案
我的代码在
下models.py
class MeasuredController(MeasuredObject):
.....
tempraturemeasure = models.ManyToManyField(MeasuredTemperature, blank=True, null=True)
.....
class MeasuredTemperature(MeasuredObject):
......
temperature = models.DecimalField(max_digits=6,decimal_places=1,verbose_name='Temperature[C]') .....
admin.py
class MeasuredControllerAdmin( admin.ModelAdmin):
list_display = ('tem0', 'tem1', 'tem2')
def tem2(self, obj):
...............
return obj.tempraturemeasure.filter(deviceindex="2").latest("senddate").temperature
.......
def tem1(self, obj):
...............
return obj.tempraturemeasure.filter(deviceindex="1").latest("senddate").temperature
.......
def tem0(self, obj):
...............
return obj.tempraturemeasure.filter(deviceindex="0").latest("senddate").temperature
.......
我的问题是否可以对admin中的tem0
,tem1
,tem2
列进行排序
答案 0 :(得分:0)
您可以通过创建子查询来完成此操作,请尝试这样
request.getParameter("")