我有以下型號:ModelForms和ForeignKeys
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'
我現在想要一個下拉菜單,用戶可以選擇的項目,新的收據應該是。用戶應該只能看到他分配的項目。 我該怎麼做?