开发者

How to use the same template for different query sets?

开发者 https://www.devze.com 2022-12-31 16:55 出处:网络
I\'m new to Django and setting up my first site. I have a Share model and a template called s开发者_如何学运维hare_list.html that uses an object_list like this:

I'm new to Django and setting up my first site. I have a Share model and a template called s开发者_如何学运维hare_list.html that uses an object_list like this:

{% for object in object_list %}

I setup haystack using their tutorial and the search template looks like this:

{% for result in page.object_list %}

I would like to modify the search.html template to have an include of the share_list so I don't have to repeat myself. How can I make it use the same object_list?


With with tag :)

{% with page.object_list as object_list %}
    {% include 'share_list.html' %}
{% endwith %}


Change the names of the dict keys you use when you render the template.

0

精彩评论

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

关注公众号