我试图使用Django过滤器使这个for查询工作。有什么帮助吗
tmp = TemporaryLesson.objects.filter(Q(expiration_date__gte=now()) | Q(expiration_date__isnull=True))
temporary_lessons = []
for t in tmp: # How to make this manual query works in the filter above?
for c in t.related_courses:
if c in student.my_courses:
temporary_lessons.append(t)
break
编辑: 模型变量
来自学生
my_courses = models.ManyToManyField(
'course.BaseCourse',
related_name='students',
through=CourseXStudent
)
从临时课程
related_courses = models.ManyToManyField(
'course.BaseCourse',
related_name='temporary_lessons'
)
目前没有回答
相关问题 更多 >
编程相关推荐