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 %}
Should be:
<td>{{ value }}</td>
not
<td>{{ value }}<td>