Last active
March 29, 2016 15:19
-
-
Save craigderington/9e2410e1ae86a65b1eb0 to your computer and use it in GitHub Desktop.
Django Tables2 - Create Customer Data Table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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