开发者

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

开发者 https://www.devze.com 2022-12-08 18:35 出处:网络
In my view to render my template I receive different parameters through my request. According to these parameters I need to render d开发者_StackOverflow社区ifferent \"part\" in my templates.

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

According to these parameters I need to render d开发者_StackOverflow社区ifferent "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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号