views.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:django-happenings 作者: natgeosociety 项目源码 文件源码
def get_context_data(self, **kwargs):
        context = super(EventDetailView, self).get_context_data(**kwargs)
        context.update(self.extra_context)

        if self.object.is_archived():
            self.template_name = 'happenings/404.html'
        elif self.object.event_type == 'current exhibition' and self.object.end_date() < datetime.datetime.today():
            self.template_name = 'happenings/detail/past-exhibition.html'
        elif self.object.parent is not None:
            self.template_name = 'happenings/detail/child.html'
        elif self.object.child_events.all():
            self.template_name = 'happenings/detail/parent.html'
        else:
            self.template_name = 'happenings/detail/%s.html' % slugify(self.object.event_type)

        return context
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号