这些是我的Django模型:
class Videos(models.Model):
Title = models.CharField(max_length=100, unique=False, help_text='video title')
Description = models.TextField(null=True, unique=False, blank=True)
Tags = models.CharField(max_length=250, unique=False, blank=True)
Category = models.CharField("Category", max_length=32, default='28', choices=CATEGORIES, null=False, blank=False)
Language = models.CharField("Language", max_length=32, default='EN', choices=LANGUAGES, null=False, blank=False)
file = models.FileField(upload_to='videos/', null=True, blank=False, validators=[FileExtensionValidator(allowed_extensions=['mp4'])] )
Playlist = models.CharField(max_length=100, unique=False)
title_gen = models.BooleanField(default=False)
class TitleVideo(models.Model):
video = models.ForeignKey(Videos, related_name='video_id', null=False, blank=False, on_delete=models.CASCADE)
converted = models.BooleanField(
default=False, help_text='video has ben converted (True | False)')
publicato = models.BooleanField(
default=False, help_text='video has ben published (True | False)')
我需要获取所有具有TitleVideo.converted = false和Videos.title_gen = True的视频,我该怎么做?
答案 0 :(得分:0)
也许尝试:
from django.db.models import Q
将导致
Video.objects.filter(Q(title_gen=True) & Q(video_id__converted=False))