Rendering different part of templates according to the request values in Django

谁说胖子不能爱 提交于 2019-12-11 16:55:35

问题


In my view to render my template I receive different parameters through my request.

According to these parameters I need to render different "part" in my templates.

For example let say that if I receive in my request

to_render = ["table", "bar_chart"]

I want to render a partial template for table and an other for bar_chart

to_render = ["bar_chart", "line_chart"]

Then I will want to render a partial template for the bar_chart and an other for line_chart

Can I define this in my view?

Or do I have to manage this in my template?

Thank you!


回答1:


just manage it in your template




回答2:


Sure, you can manage this in your view. The template API shows clearly how to use the templating system in Python.



来源:https://stackoverflow.com/questions/1592331/rendering-different-part-of-templates-according-to-the-request-values-in-django

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