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>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/EMh7NmmsumwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to