Dynamic blocks in django templates

爷,独闯天下 提交于 2020-01-06 04:27:06

问题


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 ?


回答1:


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

Edit: more specifically, look at inclusion template tags.



来源:https://stackoverflow.com/questions/3965819/dynamic-blocks-in-django-templates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!