本文整理匯總了Python中core.models.Event.get方法的典型用法代碼示例。如果您正苦於以下問題:Python Event.get方法的具體用法?Python Event.get怎麽用?Python Event.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core.models.Event
的用法示例。
在下文中一共展示了Event.get方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ical
# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import get [as 別名]
def ical(request, event_key):
event = Event.get(event_key)
if event is None:
return render_json_response({'error': '404 not found'}, mimetype='application/json', status=404)
cal = icalendar.Calendar()
eve = icalendar.Event()
eve['dtstart'] = event.event_date.strftime('%Y%m%dT%H%M%S')
eve['created'] = event.created_at.strftime('%Y%m%dT%H%M%S')
eve['last-modified'] = event.updated_at.strftime('%Y%m%dT%H%M%S')
eve['summary'] = event.title
eve['description'] = event.description
eve['event_key'] = event_key
eve['updated_log'] = event.updated_log
cal.add_component(eve)
return Response(cal.to_ical(), status=200, mimetype="text/calendar",
headers={'Content-Disposition': 'inline; filename=event.ics'})