In admin.py:
class ObjectAdmin(admin.ModelAdmin):
ordering = ['order']
Is there a way to order in reverse?
You can order the fields as you wish using the ModelAdmin. fields option. The order of fields would depend on the order in which you declare them in your models. So alternatively you could order the fields in the way you would want them to show in the admin.
The Django framework comes with a powerful administrative tool called admin. You can use it out of the box to quickly add, delete, or edit any database model from a web interface. But with a little extra code, you can customize the Django admin to take your admin capabilities to the next level.
Prepend -
to order descending.
class ObjectAdmin(admin.ModelAdmin):
ordering = ['-order']
# ^
See Model Meta options | Django documentation - ordering
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With