[Answer]-Add columns to queryset and django-table2 table

1👍

class Person(models.Model):
    # ...

    @property age(self):
        result_age = 'some queryset that return one column and one row' or datetime.date.today() - self.dob
        return result_age


class PersonTable(tables.Table):
    age = tables.Column('Custom name', order_by=('dob', ))  #  you cannot order by property, so put dob or orderable=False 

    class Meta:
        model = Person

Leave a comment