How to ordering category items a to z in django admin panel?

I have a business directory and when i add new company, categories listing mixed style. How can i order categories a to z.

I added my model these meta ordering but didn't worked.

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

enter image description here

you can write a class in your file for example

from django.contrib import admin
from .models import Category

class CategoryAdmin(admin.ModelAdmin):
    ordering = ['name'],CategoryAdmin)

hope it helps :)

Back to Top