当前位置: 首页>>代码示例>>Python>>正文


Python Event.refresh_from_db方法代码示例

本文整理汇总了Python中event.models.Event.refresh_from_db方法的典型用法代码示例。如果您正苦于以下问题:Python Event.refresh_from_db方法的具体用法?Python Event.refresh_from_db怎么用?Python Event.refresh_from_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在event.models.Event的用法示例。


在下文中一共展示了Event.refresh_from_db方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save

# 需要导入模块: from event.models import Event [as 别名]
# 或者: from event.models.Event import refresh_from_db [as 别名]
 def save(self):
     id_ = self.cleaned_data.get('id')
     title = self.cleaned_data.get('title')
     description = self.cleaned_data.get('description')
     category = self.cleaned_data.get('category')
     event_time = self.cleaned_data.get('event_time')
     event_place = self.cleaned_data.get('event_place')
     cancelled = self.cleaned_data.get('cancelled')
     event_image = self.cleaned_data.get('event_image')
     designation = self.cleaned_data.get('designation')
     notify_users = self.cleaned_data.get('notify_users')
     if id_ is not None and id_ != -1:
         created = False
         event = Event.objects.get(pk=id_)
         event.title = title
         event.description = description
         event.category = category
         event.event_time = event_time
         event.event_place = event_place
         event.cancelled = cancelled
         event.posted_by_id = designation
     else:
         created = True
         event = Event(title=title,
                       description=description,
                       category=category,
                       event_time=event_time,
                       event_place=event_place,
                       cancelled=cancelled,
                       posted_by_id=designation)
         notify_users = True
     event.save()
     if event_image is not None and event_image.image is not None:
         '''
         updating old image to just support single image for now. Should be changed in future to support multiple
         images here and at UI side
         '''
         try:
             eventImage = EventImage.objects.get(event=event)
             eventImage.image = event_image
         except EventImage.DoesNotExist:
             eventImage = EventImage(
                 event=event,
                 image=event_image
             )
         eventImage.save()
     if notify_users:
         event.refresh_from_db()
         event_signals.event_done.send(Event, instance=event, created=created)
     return event
开发者ID:the-coders-hub,项目名称:IITBApp-Server,代码行数:52,代码来源:EventForm.py


注:本文中的event.models.Event.refresh_from_db方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。