Django 中两个模型之间的关系
这似乎是一个微不足道的问题,但我对 Django 很陌生。我有两个模型用户和竞争。
用户可以创建并参加一项或多项比赛。 当用户可以是竞赛的所有者并且可以是一个或多个竞赛的参与者时,如何指定这种关系。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您有两个表
User
和Competition
:然后在竞争中您可以使用
models.ManyToManyField
示例
I Assume You have two tables
User
andCompetition
:then in competition you can user
models.ManyToManyField
Example