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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:40:24+00:00 2026-06-05T07:40:24+00:00

I have a simple poll application with models like these: class Question(models.Model): text =

  • 0

I have a simple poll application with models like these:

class Question(models.Model):
    text = models.CharField(max_length=250)
    position = models.PositiveIntegerField(default=0)

class Variant(models.Model):
    question = models.ForeignKey(Question, related_name=u"variants")
    text = models.CharField(max_length=250)
    position = models.PositiveIntegerField(default=0)

I’d like these variants to be sorted in admin changelist by question first, and then by position so that they wouldn’t mix up with variants from other questions. But simply specifying an ordering in ModelAdmin takes no effect:

class VariantAdmin(admin.ModelAdmin):
    list_display = ['text', 'question', 'position']
    ordering = ['question', '-position']

The variants with bigger position are listed upper in despite of the ‘question’ ordering.

Is there a way to get this done?

  • 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-05T07:40:26+00:00Added an answer on June 5, 2026 at 7:40 am

    During the writing of this question I tried to find the solution and eventually found it.

    The model “Variant” had an ordering specified in Meta class:

    class Variant(models.Model):
        question = models.ForeignKey(Question, related_name=u"variants")
        text = models.CharField(max_length=250)
        position = models.PositiveIntegerField(default=0)
    
        class Meta:
            ordering = ['-position']
    

    This was overriding the ordering set in the model admin. After deleting this all started to work as expected.

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

Sidebar

Related Questions

I want to create simple poll system. I have two question and two answers.
I have a simple poll site. I would like to disallow possibility of voting
I have a long-running console-based application Sender that sends simple text to STDOUT using
I want to create simple poll system. I have two question and two answers.
I have simple example: function File(name) { this.name = name this.text = null }
I have simple component - CommandButton <tr:commandButton text=test styleClass=form-button actionBean=#{testPage} action=synchAction partialSubmit=true id=btnId />
I have simple Entitly class with the @EmbeddedId ( Integer and String fields in
Trying to setup a simple Thread/Poll table mapping. Here is what I have: Threads
Is it possible to have a WinForms application make a simple call to an
I'm writing an application in which I'd like to have near real time collaborative

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.