Reputation: 3225
I am trying to query all Restaurants and show them to the user in my model but i can't get the template to show the items in the model
{% 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))
is it a spelling mistake, All I want is to see a list of restaurants.
if I remove .name after restraunt my browser shows
restaurants restaurants restaurants restaurants restaurants restaurants restaurants restaurants restaurants restaurants restaurants
even though there are only 2 entries
Upvotes: 0
Views: 864
Reputation: 13328
You need to remove the quotation marks around the restaurants
variable (and you don't need the comma either) -
return render(request,'menu/restaurants.html', {"restaurants": restaurants})
Also render
doesn't require you to set the context_instance
.
Upvotes: 1