The docs say:
Where the table is backed by a model, the database will handle the ordering. Where this is not the case, the Python cmp function is used and the following mechanism is used as a fallback when comparing across different types: ...
But is this possible in a table that is backed by a model, on a custom column? e.g.
class MyModel(models.Model):
x = models.IntegerField()
y = models.IntegerField()
def z(self):
return x+y
class MyTable(tables.Table):
z = tables.Column()
class Meta:
model = MyModel
When I try something like this, the column displays OK, but when I click on the column header to sort, I get this error:
Caught FieldError while rendering: Cannot resolve keyword u'z' into field. Choices are: ...
Apparently this is because z is not found in the database table.
Is there a way around this?