Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8074323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:36:55+00:00 2026-06-05T14:36:55+00:00

I display a database table using django-tables2. All appears OK, but clicking on the

  • 0

I display a database table using django-tables2. All appears OK, but clicking on the column headers does not sort by that column. The headers are clickable, but in their html has no url text in it, e.g.:

<div class="table-container">
<table class="paleblue"><thead><tr><th class="id orderable sortable"><a href="">ID</a>
</th><th class="orderable sortable system"><a href="">System</a></th> ...

I checked the django-tables2 template source and it sais this:

... <a href="{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}"> ...

Which I do not understand.

I can only make sorting work by setting order_by in view.py:

class ResultsTable(tables.Table):
    class Meta:
        model = Performance
        attrs = {'class': 'paleblue'}
        order_by_field = True

def result(request, system):
    results = Performance.objects.filter(system__name=system)
    table = ResultsTable(results, order_by=('<any column name from Performance>',))
    RequestConfig(request).configure(table)
    return render_to_response('result.html', {'table': table})

but that obviously only works for one column and I want to click on columns to choose which one to sort by.

It is my understanding from the docs that sorting by column should work ‘out of the box’, is this correct, or am I doing something else wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:36:56+00:00Added an answer on June 5, 2026 at 2:36 pm

    Found the answer to my own question, after a night of sleep and a fresh look and word-by-word comparison of my code with the examples in the django-tables2 docs.

    For the result function I used:

    return render_to_response('result.html', {'table': table})
    

    If I replace that with:

    return render(request, 'result.html', {'table': table})
    

    Sorting works as expected.
    Don’t ask me why…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using sessions to receive my info from my database table... But I'm not
I'm using the W3 Schools example: http://www.w3schools.com/PHP/php_ajax_database.asp to display a table of database data
I display the contents of a table in the database using a ListBox. Each
I Want to Display Database Table In My JSP Page. I Am Using JQuery
I'm using an Ajax Web Table to display the data shown in a database/table.
I'm using http://keith-wood.name/countdown.html . Each 'Event' table in my database has a 'date' column.
I am using jqGrid to display the database table and loading the JQGrid using
I am using XMLType column in some of my oracle database table. Earlier(in 11.2.0.2)
I have a large database table that I need to display on a Windows
OK folks, I am trying to display the contents of a database table along

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.