鉴于以下模型:
class Stream(models.Model):
name = models.CharField(max_length=32)
label = models.CharField(max_length=32)
...
class Data(models.Model):
class Meta:
ordering = ['timestamp']
timestamp = models.DateTimeField(db_index=True) # in UTC !
data = models.FloatField()
stream = models.ForeignKey(to=Stream, editable=False)
...
我需要以下列(CSV)格式输出结果:
示例输出:
Timestamp,A,B,C,D
2017/03/03:00:01:00,4,2,1.9,3
2017/03/03:00:01:15,4,3,1.8.3
...
A,B,C和D是流标签。
值来自Data.data字段。