我正在尝试django-tables2
在我的项目中使用。
这是我的模型
class Client(models.Model):
comp = models.ForeignKey(Company)
user = models.ForeignKey(User)
def __unicode__(self):
return u'%s\'s client data' % self.user
class Meta:
unique_together = (('user', 'comp'))
我的桌子
class ClientTable(tables.Table):
class Meta:
model = Client
fields = ('user')
empty_text = _('No client')
我的观点
@login_required
def client_list(request):
obj = {}
try:
clients = request.user.staff.company.client_set.all()
client_table = ClientTable(clients) # <-- error from here
except Staff.DoesNotExist:
raise Http404
obj['client_table'] = client_table
obj['client_nb'] = clients.count()
return render_to_response('company/client_list.html',
obj, context_instance=RequestContext(request),)
这给了我这个错误:
无法连接'str'和'tuple'对象
...
/usr/local/lib/python2.7/dist-packages/django_tables2/tables.py init
self._sequence = Sequence(self._meta.fields + ('. ..',))