简体   繁体   中英

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

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!

只需在您的模板中进行管理

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM