根据Django中的请求值渲染不同部分的模板 [英] Rendering different part of templates according to the request values in Django

查看:128
本文介绍了根据Django中的请求值渲染不同部分的模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



根据这些参数,我需要在我的模板中渲染不同的part。 / p>

例如让我们说如果我收到我的请求

  to_render = [table,bar_chart] 

我要呈现表格和部分模板另一个为bar_chart

  to_render = [bar_chart,line_chart] 
/ pre>

然后,我将要为bar_chart呈现一个部分模板,另一个用于line_chart



可以我在我的看法中定义了这一点?



或者我必须在我的模板中管理这个?



谢谢

解决方案

只需在模板中管理


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!

解决方案

just manage it in your template

这篇关于根据Django中的请求值渲染不同部分的模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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