0

I want to change the sort of my models in the admin panel with django. For example, I want to have the "categories" on the top of the list.

How can I do that?

class SongAdmin(admin.ModelAdmin):
    list_display = ['name', 'artist', 'album', 'slug']
    list_filter = ['created_date']
    search_fields = ['name', 'artist__name', 'album__name']
    
    class Meta:
        model = song

admin.site.register(song, SongAdmin)
admin.site.register(categories)
admin.site.register(album)
admin.site.register(artist)
admin.site.register(PlayList)
admin.site.register(PlayListSongs)
admin.site.register(discount_codes)

enter image description here

Arman
  • 1
  • 1
  • 1
    Is [this](https://books.agiliq.com/projects/django-admin-cookbook/en/latest/set_ordering.html) answering your question? – Raida Mar 31 '22 at 16:17
  • https://books.agiliq.com/projects/django-admin-cookbook/en/latest/set_ordering.html –  Mar 31 '22 at 16:18

1 Answers1

-1

you will need to add ordering to your meta, for example

ordering = ['name']

cedars
  • 13
  • 4