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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:22:37+00:00 2026-05-23T13:22:37+00:00

I have in my models.py class Business(models.Model): industry = models.models.ManyToManyField(Industry) in forms.py class BusinessForm(forms.ModelForm):

  • 0

I have in my models.py

class Business(models.Model):
   industry = models.models.ManyToManyField(Industry)

in forms.py

class BusinessForm(forms.ModelForm):
    class Meta:
        model = Business

When I render the form, the industry names appear in a multiple select box. What do I do to make the industry names in alphabetical order?

  • 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-05-23T13:22:37+00:00Added an answer on May 23, 2026 at 1:22 pm

    There are several ways:

    You can override the queryset ordering on a per-form basis, set the ordering meta class option, or override the model manager queryset with an ordering method.

    Override global model manager queryset

    class IndustryManager(models.Manager):
        def get_query_set(self):
            return (
                super(IndustryManager, self)
                .get_query_set()
                .order_by('name')
            )
    
    class Industry(models.Model):
        name = models.CharField(max_length=128)
        objects = IndustryManager()
    

    Specify global meta option ordering

    class Industry(models.Model):
        name = models.CharField(max_length=128)
    
        class Meta:
            ordering = ['name']
    

    Per form ordering

    class MyForm(forms.ModelForm):
        class Meta:
            model = Business
    
        def __init__(self, *args, **kwargs):
            super(MyForm, self).__init__(*args, **kwargs)   
            self.fields['industry'].queryset = Industry.objects.order_by('name')
    

    There’s also a shortcut called formfield_for_manytomany if you are dealing with the django admin.

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

Sidebar

Related Questions

I have a basic Django model like: class Business(models.Model): name = models.CharField(max_length=200, unique=True) email
I have a rather generic model, as follows: class Keyword(models.Model): ancestors = models.ManyToManyField(Keyword) name
This is my model class Business(models.Model): business_type = models.ManyToManyField(BusinessType) establishment_type = models.ForeignKey(EstablishmentType) website =
I have a Model that looks something like this: class Business(models.Model): name = models.CharField('business
In my business model I have Entity class (IPoint interface ) that has a
I have two models: class Actor(models.Model): name = models.CharField(max_length=30, unique = True) event =
I have a ViewModel class to encapsulate Personal and Business models. My problem is
I have the following models: class Category(models.Model): name = models.CharField(max_length=200) slug = models.SlugField() parent
I have the following models: class Product(models.Model): active = models.BooleanField(default=True) name = models.CharField(max_length=40, unique=True)
I have the following Django models: class Contact(models.Model): id #primary key #Other contact info

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.