【问题标题】:How can I push events into someone's google calendar from pythyon/django?如何从 python/django 将事件推送到某人的谷歌日历中?
【发布时间】:2010-10-29 19:30:43
【问题描述】:

我想要从 Python Django 将事件推送到用户的 Google 日历中的最简单和最简单的方法。我不想阅读他们的活动或做任何其他事情,只需将他们在我的应用程序中创建的活动推送到他们的 Google 日历一次即可。

其次是可能删除他们谷歌日历中的事件(如果我推送的事件被删除)。

【问题讨论】:

    标签: django google-calendar-api


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      这是一个sn-p来做的:

      from django import template
      from django.contrib.sites.models import Site
      from django.utils.http import urlquote_plus
      
      register = template.Library()
      
      @register.filter
      def google_calendarize(event):
          st = event.start
          en = event.end and event.end or event.start
          tfmt = '%Y%m%dT000000'
      
          dates = '%s%s%s' % (st.strftime(tfmt), '%2F', en.strftime(tfmt))
          name = urlquote_plus(event.name)
      
          s = ('http://www.google.com/calendar/event?action=TEMPLATE&' +
           'text=' + name + '&' +
           'dates=' + dates + '&' +
           'sprop=website:' + urlquote_plus(Site.objects.get_current().domain))
      
          if event.location:
              s = s + '&location=' + urlquote_plus(event.location)
      
          return s + '&trp=false'
      
      google_calendarize.safe = True
      

      这段代码可以通过以下方式调用:

      {% load project_events_tags %}
      ...
      <a href="{{ event|google_calendarize }}">+ Add to Google Calendar</a>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-07-31
        • 2018-04-30
        相关资源
        最近更新 更多