我有一个项目模型。该项目包含人员(从事该项目的人员)。我也在尝试为每个项目人员制作一个模型,包括他们对项目的任何注释和项目完成百分比。
我的问题是我想只过滤individual_person_in_project
相应项目中的人员。我正在尝试使用
limit_choices_to = {'person_in_project':User}
我想将我的选择限制为我Project
模型中的用户。
class Project(models.Model):
project_name = models.CharField(max_length = 120,null = False,blank = False)
project_percent_complete = models.IntegerField(blank = True,null = True, default = 0)
person_in_project = models.ManyToManyField(User,related_name = 'project_person',blank = True)
project_description = models.CharField(max_length = 300,null = True,blank = True)
class Project_Person(models.Model):
corresponding_project = models.ForeignKey(Project,related_name = 'corresponding_project_this_user_is_in',null = False)
individual_person_in_project = models.ForeignKey(User, related_name = 'a_person_within_the_corresponding_project', limit_choices_to = {'person_in_project':User})
percent_complete = models.IntegerField(default = 0)