Django admin select box ordering

How to order foreign key values โ€‹โ€‹in Django admin?

Example:

LeaveBase class (models.Model):

 User = models.ForeignKey(User,verbose_name=('User Name'))    
 FinancialYear=models.ForeignKey(FinancialYear,verbose_name=('Financial Year'))

In my Django admin, when I add a new separation base, the User column shows how the select box with the default order by id, I would like to order its name.

+3
source share

Source: https://habr.com/ru/post/1777009/


All Articles