我有以下型号:
class Project(models.Model):
name = models.CharField(max_length=50)
class ProjectParticipation(models.Model):
user = models.ForeignKey(User)
project = models.ForeignKey(Project)
class Receipt(models.Model):
project_participation = models.ForeignKey(ProjectParticipation)
此外,我有以下 CreateView:
class ReceiptCreateView(LoginRequiredMixin, CreateView):
form_class = ReceiptForm
model = Receipt
action = 'created'
我现在想要一个下拉菜单,用户可以在其中选择项目,新收据应该用于。用户应该只看到他被分配到的项目。我怎样才能做到这一点?