Skip to content

Instantly share code, notes, and snippets.

@craigderington craigderington/tables.py
Last active Mar 29, 2016

Embed
What would you like to do?
Django Tables2 - Create Customer Data Table
import django_tables2 as tables
from django_tables2.utils import A
from .models import Customer
class CustomerTable(tables.Table):
account_number = tables.LinkColumn('customer-detail', args=[A('pk')])
customer_first_name = tables.LinkColumn('customer-detail', args=[A('pk')])
customer_last_name = tables.LinkColumn('customer-detail', args=[A('pk')])
customer_email = tables.LinkColumn('customer-detail', args=[A('pk')])
class Meta:
model = Customer
fields = ('account_number', 'customer_first_name',
'customer_last_name', 'primary_phone', 'city',
'state', 'customer_email')
attrs = {"class": "table-striped table-bordered"}
empty_text = "There are no customers matching the search criteria..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.