本文整理汇总了Python中events.models.Event.year方法的典型用法代码示例。如果您正苦于以下问题:Python Event.year方法的具体用法?Python Event.year怎么用?Python Event.year使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类events.models.Event
的用法示例。
在下文中一共展示了Event.year方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from events.models import Event [as 别名]
# 或者: from events.models.Event import year [as 别名]
def handle(self, *args, **options):
Event.objects.all().delete()
Person.objects.all().delete()
EventPerson.objects.all().delete()
Settings.objects.all().delete()
import_obj = json.loads(sys.stdin.read())
for person in import_obj['people']:
Person.objects.create(name=import_obj['people'][person]['name'])
for event_obj in import_obj['events']:
event = Event(title=event_obj['title'])
if 'year' in event_obj:
event.year = event_obj['year']
if 'month' in event_obj:
event.month = event_obj['month']
if 'day' in event_obj:
event.day = event_obj['day']
if 'z' in event_obj:
event.z = event_obj['z']
event.save()
participants = []
participant_rank = 0
for participant in event_obj['participants']:
name = import_obj['people'][str(participant)]['name']
people_with_that_name = Person.objects.filter(name=name)
person = people_with_that_name[0]
ep = EventPerson.objects.create(
number = participant_rank,
event = event,
participant = person
)
participant_rank += 10
settings = Settings.objects.create(
title = import_obj['settings']['title'],
description = import_obj['settings']['description'],
string_people = import_obj['settings']['string_people'],
string_no_people = import_obj['settings']['string_no_people'],
string_events = import_obj['settings']['string_events'],
string_no_events = import_obj['settings']['string_no_events'],
string_links = import_obj['settings']['string_links'],
string_no_links = import_obj['settings']['string_no_links'],
string_comments = import_obj['settings']['string_comments'],
string_no_comments = import_obj['settings']['string_no_comments'],
string_add_comment = import_obj['settings']['string_add_comment'],
string_send = import_obj['settings']['string_send'],
)