Skip to content

Instantly share code, notes, and snippets.

@craigderington
Last active March 29, 2016 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigderington/9e2410e1ae86a65b1eb0 to your computer and use it in GitHub Desktop.
Save craigderington/9e2410e1ae86a65b1eb0 to your computer and use it in GitHub Desktop.
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