Py学习  »  Django

初学者问个有关include的问题

jerry • 10 年前 • 2754 次点击  

sample.htm

<h1>Hello, {{name}}!<h1>

index.html

{% include "sample.html" %}
{% include "sample.html" %}

views.py

def home(request):
    return render(request, "index.html",
        context_instance=RequestContext(request, {"name": "jerry"})

现在的问题是,用户访问home视图对应的URL时,页面上将显示两行jerry,有没有社么办法让index.html中两次不同的include接收不同的参数呢?或者有没有办法在sample.html中通过某种指示以便获取不同的参数?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/709
 
2754 次点击  
文章 [ 1 ]  |  最新文章 10 年前