one-to-many relationships with django -


i intend create teaming system, each team may contain multiple contestants. contestants auth.user. similar to:

team:       contestant1     contestant2     .     .     contestantn 

since contestant user cannot modify have foreignkey team. best way achieve this?

the ways though was:

  • create onetoone profile user points team.
  • define manytomany relationship between user , team user has unique.

a pause

i redesigning structure of application, rephrase question again
replies, consider them , see if 1 of them fits.

you can this:

class team(models.model):     contestants = models.manytomanyfield(user, through='contestant')  class contestant(models.model):     team = models.foreignkey(team)     user = models.foreignkey(user)     [here go contestant data fields] 

this allows 1 user take part in different teams, if don't want allow this, can add unique=true contestant.user.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -