django模板中的动态块 [英] Dynamic blocks in django templates

查看:136
本文介绍了django模板中的动态块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个关于django的问题,对我来说绝对没有答案。
假设我有一个网站,我在侧边栏中显示两个块:


  1. 最后一个用户的列表登录

  2. 最近发布的博客文章列表

让我们说这些块是显示在80%的网站网址上,并使用模板文件呈现。
这些块的数据由代码(显式)生成,bt不是通过url视图。



那么怎么做这样的事情? >

解决方案

您可能需要查看自定义模板标签



修改:更具体地说, 包含模板标签


It is a question about django that has found absolutely no answer for me. Let's suppose I have a site where I display two blocks in the sidebar :

  1. A list of the last users who've logged in
  2. A list of the last published blog articles

Let's say that these blocks are to be displayed on 80% of the website urls and presented using template files. The data for these blocks is generated by code (obviously), bt not by url views.

Well, how to do such a thing ?

解决方案

You might want to take a look at custom template tags.

Edit: more specifically, look at inclusion template tags.

这篇关于django模板中的动态块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆