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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -