繁体   English   中英

Django - 为锦标赛创建 model

[英]Django - creating model for a tournament

我的 model 有问题,我不知道如何创建名为战斗的 model,因为我想从我的数据库中选择两个用户,但我不知道如何创建它

class battle(models.Model):
    user1 = models.ForeignKey(Debatants, on_delete=models.DO_NOTHING)
    user2 = models.ForeignKey(Debatants, on_delete=models.DO_NOTHING)
    judge = models.ForeignKey(Judges, on_delete=models.DO_NOTHING)
    data = models.DateField(auto_now_add=False, auto_now=False)

我会很感激任何提示

尝试添加具有外键关系的唯一相关名称,

例如

user1 = models.ForeignKey(Debatants, on_delete=models.DO_NOTHING, related_name="battles")

所以辩论者把这个 model 作为战斗

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM