本文整理汇总了Python中django.utils.dates.MONTHS.keys方法的典型用法代码示例。如果您正苦于以下问题:Python MONTHS.keys方法的具体用法?Python MONTHS.keys怎么用?Python MONTHS.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.utils.dates.MONTHS
的用法示例。
在下文中一共展示了MONTHS.keys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_projects_parts_and_imputations
# 需要导入模块: from django.utils.dates import MONTHS [as 别名]
# 或者: from django.utils.dates.MONTHS import keys [as 别名]
def create_projects_parts_and_imputations(self):
max_projects = 3
for p in range(0, max_projects):
project = Project()
project.internal_id = self.sd.word() + str(p)
project.name = self.sd.word()
project.description = self.sd.paragraph()
project.active = self.sd.boolean()
project.client = Client.objects.order_by("?")[0]
project.save()
project_users = User.objects.order_by("?")[0:3]
for u in project_users:
assignation = Assignation(employee=u, project=project)
assignation.save()
for u in User.objects.all():
for year in [2011, 2012, 2013]:
for month in MONTHS.keys():
part = Part()
part.month = month
part.year = year
part.employee = u
part.state = self.sd.choice(PART_STATE_CHOICES)[0]
part.save()
for part in u.parts.all():
part.data = {}
for project in u.projects.all():
project_data = {day+1: self.sd.int(8) for day in range(monthrange(part.year, part.month)[1])}
part.data[project.id] = project_data
part.save()