开发者

return django view to template tag

开发者 https://www.devze.com 2023-02-22 01:00 出处:网络
I want have template tag... 开发者_C百科There is some view and template ( named X ), when i call this view, return some html

I want have template tag...

开发者_C百科

There is some view and template ( named X ), when i call this view, return some html

for example

<h1>hi</h1>

In index of test application, i want when call template tag in template of this view, template tag return html of named X

for example

<h2>test</h2>
{% template_Tag_return_x_view %}

result

<h2>test</h2>
<h1>hi</h1>

whats is best way?


If you want to reuse your view's logic in several places it maybe it easier to turn the view into an inclusion tag.

It's more flexible than a simple include as you can specify parameters that influence the output.


I suggest you look at the include template tag.

0

精彩评论

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

关注公众号