Reputation: 3
It seems like a trivial question but I am new to Django. I have two models user and competition.
The user can create and join one or many competition. How to specify this relation as the user can be the owner of competition/s and can be a participant in one or more competition.
Upvotes: 0
Views: 405
Reputation: 317
I Assume You have two tables User
and Competition
:
then in competition you can user models.ManyToManyField
Example
class User:
...
class Competition:
...
creator = models.ForeignKey(User)
participents = models.ManyToManyField(User)
Upvotes: 2