(tables) models.py in django-tables throws a exception when creating an instance with a sliced queryset

1 view
Skip to first unread message

Daniel Gonzalez Gasull

unread,
Jul 29, 2010, 6:31:12 PM7/29/10
to Django Apps
Hi.

If I do

initial_queryset = models.Coupon.objects.all()
queryset = initial_queryset[page*50:page*50+50]
coupons = tables.CouponTable(queryset,
order_by=request.GET.get('sort'))

Then the template will throw a TypeError in line 174 of django_tables/
models.py:

self._length = self.table.data.count()

A fix I found is changing the above line for this:

self._length = len(self.table.data)

I hope this helps.

--
http://DjanSoft.com :: Agile Application Development with Python
Reply all
Reply to author
Forward
0 new messages