headers = {'to': 'asc', 'date': 'asc', 'type': 'asc'}

def table_view(request):
    sort = request.GET.get('sort')
records = Record.objects.all()
if sort is not None:
    records = records.order_by(sort)
Sortable tables in Django