我有QuestionSet
这是一个很多问题。每个QuestionSet
都有多个questions
与之关联。
我想获得两个(或更多)questions
QuestionSets
的列表
例如:
First QuestionSet = Questions(1,2,3)
Second QuestionSet = Questions(1,3,4)
Output:
List/Queryset/Something of Questions(1,2,3,4)
models.py
class QuestionSet(models.Model):
name = models.CharField(max_length=255)
questions = models.ManyToManyField(Question)
class Question(models.Model):
question_num = models.IntegerField(default=0,blank=False)
答案 0 :(得分:1)
也许试试这个:
public class MyWatermark implements
AssignerWithPeriodicWatermarks<Tuple2<String, MyEvent>> {
private final long maxTimeLag = 5000;
@Override
public long extractTimestamp(Tuple2<String, MyEvent> event, long previousElementTimestamp) {
try {
return event.f1.eventTime;
}
catch(NullPointerException ex) {}
return System.currentTimeMillis() - maxTimeLag;
}
@Override
public Watermark getCurrentWatermark() {
return new Watermark(System.currentTimeMillis() - maxTimeLag);
}
}
您可以在文档中找到更多内容:Django aggregates