我想在 home.html 模板中显示对象,该对象主要在 laglist 模板中。我使用包含标签来执行操作,但它不起作用。以下是我的代码:
laglist.html
{% extends "base.html" %}
{% block lag %}
<h2>Lam </h2>
{% for leggo in leggos %}
<p><a href= "{% url halldetail leggo.id %}" >{{ leggo.name }}</a><p>
<img src="{{MEDIA_URL}}/{{leggo.thumbnail_1.url}}" width="83" height="78"> <img src="{{MEDIA_URL}}/{{leggo.thumbnail_2.url}}" width="83" height="78" />
<li>{{ leggo.state }}</li>
{% endfor %}
{% endblock %}
查看 laglist:
def lag_view(request):
leggos=Fin.objects.filter(state='venu')
for leggo in leggos:
print leggo.id
return render_to_response('laglist.html', {'leggos':leggos,'leggo':leggo,'Fin':Fin},context_instance=RequestContext(request))
主页.html
{% extends "base.html" %}
{% block content %}
<p> {% include 'laglist.html' %} </p>
{% endblock %}
看家
def homp(request):
return render_to_response('home.html',context_instance=RequestContext(request))