(django-tables) Getting empty cells

23 views
Skip to first unread message

ALJ

unread,
Feb 28, 2010, 2:44:26 PM2/28/10
to Django Apps
I am trying to use django-tables with modeltable but every other cell
is empty

Any ideas?

(Django 1.1)

#Output >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<table>
<tbody><tr>

<th><a href="?sort=id">Id</a></th>

<th><a href="?sort=first_name">First name</a></th>

<th><a href="?sort=last_name">Last name</a></th>

</tr>

<tr>

<td>2</td><td>

</td><td>another</td><td>

</td><td>person</td><td>

</td></tr>

<tr>

<td>1</td><td>

</td><td>Big</td><td>

</td><td>Fred</td><td>

</td></tr>

</tbody></table>

#models.py>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
from django.db import models

class People(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
def __unicode__(self):
return "%s %s" % (self.first_name, self.last_name)

#view.py>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
from mysite.bespoke.models import People
import django_tables as tables

class PeopleList(tables.ModelTable):
class Meta:
model = People

def test(request):
qs = People.objects.all()
table = PeopleList(qs,
order_by=request.GET.get('sort','some_field'))

return render_to_response('test.html',{'table':table})

#test.html >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
{% extends "base.html" %}
{% load mytags %}
{% load pagination_tags %}
{% autopaginate rows 10 %}

{% block content %}
<table>
<tr>
{% for column in table.columns %}
<th><a href="?sort={{ column.name }}">{{ column }}</a></th>
{% endfor %}
</tr>
{% for row in table.rows %}
<tr>
{% for value in row %}
<td>{{ value }}<td>
{% endfor %}
</tr>
{% endfor %}
</table>
{% endblock %}

ALJ

unread,
Mar 1, 2010, 5:18:54 AM3/1/10
to Django Apps
After spending ages looking through the code the problem is actually
more obvious. The problem is with the example from the website (http://
blog.elsdoerfer.name/2008/07/09/django-tables-a-queryset-renderer/).
There is a slash missing.

Should be:

<td>{{ value }}</td>

not

<td>{{ value }}<td>

Reply all
Reply to author
Forward
0 new messages