Django预定(模板)模块

时间:2011-01-21 22:34:40

标签: django templates scheduling

我要做的是在我的网站上构建“动态”模块。

假设我有一个博客,有两列。

左栏包含帖子,右栏包含“modules”(“最受欢迎的帖子”,“标签”等)。

某些模块无关到帖子(例如“标签”),有些模块将独立(例如, Blog Roll )。

模板级别 - “包含”这些模块的最佳方式是什么?(每个模块都有不同的标记/不同型号)。

后端级别 - 如何向“无关”模块添加计划,以便在特定日期/小时内显示?

1 个答案:

答案 0 :(得分:2)

使用include和block标签 http://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance

根据某个变量显示内容。你可以做这样的事情 在视图中

def foo(request):
    if day=="monday":
       show_tags=True
    else:
       show_tags=False
    return render_to_response('template.html', {'show_tags': show_tags})

并在template.html中

{% if show_tags %}
   {% include 'tags_template.html' %}
{% endif %}