如何通过fileto从manytomanyfield注释字段

时间:2016-10-26 05:43:18

标签: python django

我的模特

class Project(models.Model):
    name = models.CharField(max_length=255, unique=True)
    info = models.CharField(max_length=255, unique=True)
    m2mStatus = models.ManyToManyField("ProjectStatus")

class ProjectStatus(models.Model):
    status = models.BooleanField(default=False)
    startTime = models.DateTimeField(auto_now=True)
    description = models.CharField(max_length=255)

我想这样注释:

pj = Project.objects.filter(name="abc")
ps = pj.m2mStatus.last()
Project.objects.filter(name="abc").annotate(status=ps.status)

任何帮助?

0 个答案:

没有答案