django - ModelForms and ForeignKeys -
i got following models:
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)
furthermore have following createview:
class receiptcreateview(loginrequiredmixin, createview): form_class = receiptform model = receipt action = 'created'
i want dropdown menu user can choose project, new receipt should for. user should see project assigned to. how can that?
the answer create model form read docs, fundamental.
you may want @ related names, way can reverse on fk.
class projectparticipation(models.model): user = models.foreignkey(user) project = models.foreignkey(project, related_name='projectparticipation')
Comments
Post a Comment