ForeignKey dropdown sorting in Admin
|Reported by:||Rob van der Linde||Owned by:||nobody|
|Severity:||Normal||Keywords:||ForeignKey sort ordering|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have a model with a unique ForeignKey field called "user" to the django.contrib.auth User model. When I edit the model in admin, the dropdown list shows users in the order they are in the database, not sorted.
I would like to be able to sort the users in the dropdown list alphabetically, but cannot see a way how I can do this currently.
Considering the User model already has an ordering field in the UserAdmin class (django.contrib.auth.admin), would it be possible to also use this field for sorting the data in a ForeignKey dropdown box?