类注册(models.Model): user = models.OneToOneField(User,related_name =' customer',on_delete = models.CASCADE) DOB = models.DateField(null = True,blank = True,默认='') post_code = models.CharField(max_length = 10) area = models.TextField()
# account type choices
OWNER = 'OW'
WRITER = 'WR'
ANALYST = 'AN'
REFEREE = 'RE'
ACCOUNT_TYPE_CHOICES = (
(OWNER, 'League wner'),
(WRITER, 'Sports Writer'),
(REFEREE, 'Referee'),
(ANALYST, 'Analyst'),
)
account_type = models.CharField(
max_length=2,
choices=ACCOUNT_TYPE_CHOICES,
default=REFEREE,
)
activation_key = models.CharField(max_length=255, null=True, blank=True)
activation_time = models.DateTimeField(auto_now_add=True, null=True, blank=True)
is_activate = models.BooleanField(default=False, blank=True)
is_admin_accepted = models.BooleanField(default=False, blank=True)
# this is included to keep record . Eiher this user has already been rejected by Admin
is_admin_rejected = models.BooleanField(default=False, blank=True)
def __str__(self):
return (self.user.username)
class Match(models.Model): GAME_HOUR =( (9,' 9'), (10,' 10'), (11,' 11'), (12,' 12'), (13,' 13'), (14,' 14'), (15,' 15'), (16,' 16'), (17,' 17'), (18,' 18'), (19,' 19'), (20,' 20'), (21,' 21') )
GAME_TIME = (
(00, '00'),
(10, '10'),
(15, '15'),
(20, '20'),
(30, '30'),
(45, '45')
)
MATCH_FORMAT = (
('11v11', '11v11'),
('9v9', '9v9'),
('8v8', '8v8'),
('7v7', '7v7'),
('6v6', '6v6'),
('5v5', '5v5'),
('3v3', '3v3')
)
MATCH_TYPE = (
('League', 'League'),
('Friendly', 'Friendly'),
('KickAbout', 'Kick-About')
)
team1 = models.ForeignKey(Team, on_delete=models.CASCADE, related_name='team1', null=False)
team2 = models.ForeignKey(Team, on_delete=models.CASCADE, related_name='team2', null=False)
referee = models.ForeignKey(Registration, on_delete=models.CASCADE, null=False, default='0')
match_format = models.CharField(choices=MATCH_FORMAT, null=False, max_length=20,default='5v5')
match_type = models.CharField(choices=MATCH_TYPE, null=False, max_length=20 ,default='Friendly')
accepted = models.BooleanField(null=False, default=False)
game_time = models.IntegerField(choices=GAME_TIME, null=False ,default='30')
game_hour = models.IntegerField(choices=GAME_HOUR, null=False,default='10')
date = models.DateField(null=False,default='2018-04-28')
creation_date = models.DateField(null=False,default='2018-04-28')
last_update_date = models.DateField(null=False,default='2018-04-28')
last_update_time = models.TimeField(null=True)
season_id = models.ForeignKey(Season, on_delete=models.CASCADE, related_name='Session_Id', null=False, default=2)
live = models.BooleanField(null=False, default=False)
registration = models.ForeignKey(Registration, on_delete=models.CASCADE, null=True,default=0)
match_code = models.CharField(max_length=10, default='ABC',blank=False)
match_end = models.TimeField(null=True)
played = models.BooleanField(default=False)
def str (自我): 返回" %d" %self.id
我制作了2个模型(1个注册继承了用户模型.2。匹配继承注册的模型)但是当我创建Match然后我得到错误"用户匹配查询不存在。&# 34;