本文整理汇总了Python中HVZ.main.models.Game.full_clean方法的典型用法代码示例。如果您正苦于以下问题:Python Game.full_clean方法的具体用法?Python Game.full_clean怎么用?Python Game.full_clean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HVZ.main.models.Game
的用法示例。
在下文中一共展示了Game.full_clean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from HVZ.main.models import Game [as 别名]
# 或者: from HVZ.main.models.Game import full_clean [as 别名]
def handle(self, *args, **options):
now = settings.NOW()
start_date = now.date()
# The game starts or started on a Tuesday of this week
if start_date.weekday() in (SUNDAY, MONDAY, TUESDAY):
start_date -= datetime.timedelta((TUESDAY - start_date.weekday()) % 7)
else:
start_date += datetime.timedelta((start_date.weekday() - TUESDAY) % 7)
end_date = start_date + datetime.timedelta(SATURDAY - TUESDAY)
if Game.objects.filter(start_date=start_date, end_date=end_date).exists():
self.stderr.write("You don't need to create a game!")
return
game = Game(start_date=start_date, end_date=end_date)
game.full_clean()
game.save()
self.stderr.write(
"Game created from {:%A %d} to {:%A %d}, {:%B %Y}".format(
start_date,
end_date,
start_date,
)
)