Commit a8403140 authored by Pierre-antoine Comby's avatar Pierre-antoine Comby

create Custom history table

parent 6779b9da
......@@ -106,6 +106,10 @@ class Transaction(models.Model):
super().save(*args, **kwargs)
def total(self):
return self.amount*self.quantity
class MembershipTransaction(Transaction):
membership = models.OneToOneField(
#!/usr/bin/env python
import django_tables2 as tables
from .models.transactions import Transaction
class HistoryTable(tables.Table):
class Meta:
attrs = {'class':'table table-bordered table-condensed table-striped table-hover'}
model = Transaction
template_name = 'django_tables2/bootstrap.html'
sequence = ('...','total','valid')
total = tables.Column() #will use !!
def order_total(self, QuerySet, is_descending):
# needed for rendering
QuerySet = QuerySet.annotate(
total=F('amount') * F('quantity')
).order_by(('-' if is_descending else '') + 'total')
return (QuerySet, True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment