views
create = Create.objects.filter(campaign_id=campaign_id).values()
print (create)
saved = create.produces.filter(active=True).values()
print(saved)
models
class Create(models.Model):
user = models.ForeignKey(User,on_delete= models.CASCADE,blank=True)
campaign = models.ForeignKey(Campaign,on_delete=models.CASCADE,blank=True)
produces = models.ManyToManyField(Saved,blank=True)
class Saved(models.Model):
user = models.ForeignKey(User,on_delete= models.CASCADE,blank=True)
unique_key = models.CharField(max_length=2000,default='')
text = models.CharField(max_length=2000,default='')
active = models.BooleanField(default=False,blank=True)
How to get all saved with active=True
It is giving error of
saved = create.produces.filter(active=True).values()
AttributeError: 'QuerySet' object has no attribute 'produces'
in the output of print(create) their is no produce field
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…