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 8689515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:39:59+00:00 2026-06-12T23:39:59+00:00

When using Django admin with grappelli I would like that a click on a

  • 0

When using Django admin with grappelli I would like that a click on a column header will sort the table by descending order.

(I don’t want a default ordering to the columns by defining the ordering field in the Model Meta Class.)

The default behavior is Ascending.

The first click should order like this:

required behavior

  • 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-12T23:40:00+00:00Added an answer on June 12, 2026 at 11:40 pm

    Rewrite the def result_headers(cl)

    add these 2 lines:

        .....
        .....
        th_classes = ['sortable']
        order_type = ''
    
        #new lines
    
        default_order_type = getattr(attr, "admin_order_first_type", None)
        new_order_type = default_order_type if default_order_type else 'asc'
    
        #end of new lines
    
        sort_priority = 0
        sorted = False
        ...
        ...
    

    now in the ModelAdmin you can:

    list_display = ('number_of_players', ....)
    
    def number_of_players(self, team):
            return intcomma(team.number_of_players)
    
    number_of_players.short_description = '# num of players'
    number_of_players.admin_order_field = 'number_of_players'
    number_of_players.admin_order_first_type = 'desc' #will make the column to be ordered desc first
    

    I tested it and it works

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

Sidebar

Related Questions

Using the django admin, I would like to be able to specify which models
I'm using django-admin-tools 0.4. Following the docs here so that I can get a
I am configuring django for using django admin tool, following steps in webpage http://www.ibm.com/developerworks/linux/library/l-django/?S_TACT=105AGX52&S_CMP=cn-a-l
I'm using django.contrib.admin in one of my apps. my models: class Gallery(models.Model): location =
I've been successfully using Django's admin panel for internal users for a while but
I created a database for a site i'm doing using Django as the admin
Can Django admin site select entries by a custom date range, i.e. using two
I am using Django 1.3 and have the following issue: In the Admin list
I'm using django's admin to let users manage model instances of a specific model.
We're using django-admin interface for the backoffice of our own apps, but it we

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.