import django_tables2 as tables from django_tables2.utils import A from myapp.models import Product class ProductTable(tables.Table): name = tables.Column(accessor=A('name')) price = tables.Column(accessor=A('price')) description = tables.Column(accessor=A('description')) class Meta: model = Product
import django_tables2 as tables from django_tables2.utils import A from myapp.models import Product class ProductTable(tables.Table): name = tables.Column(accessor=A('name')) price = tables.Column(accessor=A('price')) description = tables.Column(accessor=A('description')) class Meta: model = Product order_by = ('price',) table = ProductTable(Product.objects.all())In this example, the `order_by` attribute of the `Meta` class is set to `('price',)` to sort the table by the `price` field. The `A` function is used to access the `price` field on the `Product` model instances. The resulting table will be sorted by price in ascending order. This package library is part of the Django framework.