How to alphabetically order a drop-down list in Django admin?

You can define default ordering for Author model:

class Author(Model):
    name = CharField(max_length=100)

    class Meta:
        ordering = ('name',)

Keep in mind that this causes the objects in Django also to ordered and migration will have to be done.

You can do ordering = ['name'] under the AuthorAdmin file to order only for admin dashboard.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)