I have a page that I want to list all users and another page which I want to use to list all microposts. The user page works fine but the micropost page does not work even though the two look like they are of an identical format. On the micropost page, I just get an empty table.
Here is part of views.py:
def list(request):
users = User.objects.all()
return render_to_response('micropost/list.html', {'users':users})
def micropost_list(request):
mposts = Micropost.objects.all()
return render_to_response('micropost/micropost_list.html', {'mposts',mposts})
Here is list.html:
<html>
<head>
<title>
List all Users
</title>
</head>
<body>
<table border="1">
<tr><td><b>ID</b></td><td><b>Name</b></td><td><b>E-mail address</b></td></tr>
{% for u in users %}
<tr><td> {{ u.id }} </td><td> {{ u.name }} </td><td> {{ u.email }} </td></tr>
{% endfor %}
</table>
</body>
</html>
Here is micropost_list.html:
<html>
<head>
<title>
List all Microposts
</title>
</head>
<body>
<table border="1">
<tr><td><b>ID</b></td><td><b>Content</b></td><td><b>Date Posted</b></td></tr>
{% for m in mposts %}
<tr><td> {{ m.id }} </td><td> {{ m.content }} </td><td> {{ m.date }} </td></tr>
{% endfor %}
</table>
{{ mposts }}
</body>
</html>