Django only shows 15 objects...?
I have a very simple little Django 1.2 site, used to keep track of WEP keys cracked by students as a part of a lab, but I have run into a problem I can not figure out where it is: I have a template that lists solutions from the database, but it only lists 15 objects, even when there are many more (over 60) in the database table.
The view:
def index(request, message=None):
cracks_list = Crack.objects.all().order_by('-time')
return render_to_response('wifi/templates/index.html', {'cracks_list': cracks_list}, context_instance=RequestContext(request))
And the associated template:
{% if message %}<p><strong>{{ message }}</strong></p>{% endif %}
{% if cracks_list %}
<ul>
<table border="1">
<tr>
<td>Time</td>
<td>Student</td>
<td>Key</td>
</tr>
{% for crack in cracks_list %}
<tr>
<td>{{crack.time}}</td>
<td>{{crack.name}}</td>
<td>{{crack.key}}</td>
</tr>
{% endfor %}
</table>
</ul>
{% else %}
<p>No solution posted yet.</p>
{% endif %}
It seems very strange to me if I can not pass more than 15 objects to the template. And a开发者_JAVA百科s far as I can tell there is nothing strange in the database. Any ideas? I assume it is something small and silly...
Check your template input before ! If this is cracks_list print it. It will help debug !
def index(request, message=None):
cracks_list = Crack.objects.all().order_by('-time')
for i in cracks_list:
print i
return render_to_response('wifi/templates/index.html', {'cracks_list': cracks_list}, context_instance=RequestContext(request))
精彩评论