我有比赛表,我想添加比赛类型(例如决赛。 半决赛。 四分之一决赛。 第三名比赛。 第一场比赛 2.比赛 3.比赛 4.match和更多。 如果联赛中有一场比赛,甚至可能有第十场比赛 你应该建议我什么
class MatchQuerySet(models.QuerySet):
def finished(self):
return self.filter(status=Match.STATUS_FINISHED)
def started(self):
return self.filter(status=Match.STATUS_STARTED)
def playing(self):
return self.filter(status=Match.STATUS_PLAYING)
def cancelled(self):
return self.filter(status=Match.STATUS_CANCELLED)
def unknown(self):
return self.filter(status=Match.STATUS_UNKNOWN)
class Match(models.Model):
STATUS_FINISHED = 'Bitti'
STATUS_STARTED = 'Başladı'
STATUS_PLAYING= 'Oynanıyor'
STATUS_CANCELLED= 'İptal'
STATUS_UNKNOWN= 'Bilinmiyor'
STATUS_PENDING= 'Bekleniyor'
STATUSES = (
(STATUS_FINISHED, 'Bitti'),
(STATUS_STARTED, 'Başladı'),
(STATUS_PLAYING,'Oynanıyor'),
(STATUS_CANCELLED,'İptal'),
(STATUS_UNKNOWN,'Bilinmiyor'),
(STATUS_PENDING,'Bekleniyor'),
)
name=models.CharField(max_length=255)
slug=models.SlugField(unique=True,max_length=255)
status = models.CharField(max_length=20,choices=STATUSES,default=STATUS_UNKNOWN)
map=models.ForeignKey('GameMap',null=True,blank=True,related_name='matchmap',on_delete=models.PROTECT)
league=models.ManyToManyField(League,blank=True,null=True)
objects = MatchQuerySet.as_manager()