Django scheduled (template) modules
What I am开发者_JAVA技巧 trying to do is to architect "dynamic" modules on my website.
Assume I have a blog, with two columns.
Left column contains a post, right column contains "modules" ("Most popular posts", "Tags" etc).
Some of the modules will be unrelated to the post (ex. "Tags"), and some will be independent (ex.Blog Roll).
On the template level - what is the best way to "include" these modules? (each will have a different markup/different model).
On the back-end level - how can I add a schedule to the "unrelated" modules so they are displayed during particular days/hours?
use include and block tags http://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance
to display something based on some variable. you can do something like this in views
def foo(request):
if day=="monday":
show_tags=True
else:
show_tags=False
return render_to_response('template.html', {'show_tags': show_tags})
and in template.html
{% if show_tags %}
{% include 'tags_template.html' %}
{% endif %}
加载中,请稍侯......
精彩评论