我正在尝试查询所有餐厅并将它们显示给我的模型中的用户,但我无法获取模板来显示模型中的项目
{% block content %}
<h1>Featured Restraunts</h1>
<ul>
{% for restaurant in restaurants %}
<li><h2>{{ restaurants.name }}</h2></li>
{% endfor %}
</ul>
{% endblock %}
this is what i get
Featured Restaurants
and this is my views.py
def view_restaurants(request):
restaurants = Restaurant.objects.all()
return render(request,'menu/restaurants.html',{"restaurants":"restaurants",},context_instance=RequestContext(request))
是拼写错误吗,我只想查看餐厅列表。
如果我在限制浏览器显示后删除 .name
餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅餐厅
即使只有 2 个条目