[Fixed]-Django-tables2 set of columns

26👍

Example of specifying model fields

Your Model

class Product(model.Models):
    name = model.CharField(max_length=20)
    price = model.DecimalField(max_digit=9, decimal_places=2)

Your Table

class ProductTable(tables.Table):
    actions = ProductActions(orderable=False) # custom tables.Column()
    class Meta:
        model = Product
        fields = ('name', 'price', 'action') # fields to display

Also you can also use exclude

Related docs entry here

Leave a comment