Monday, December 13, 2021

Choosing label in Admin autocomplete_fields widget

In Django 3.1, we were using autocomplete_fields on Admin edit pages with some foreign keys. To improve usability, we had overridden ModelAdmin.autocomplete_view so that it would provide us with human-readable labels. Very similar to the question and solution in this Stack Overflow post: https://stackoverflow.com/questions/55629887/change-django-autocomplete-fields-label

In the move to Django 3.2, ModelAdmin.autocomplete_view was removed, causing all of our autocomplete_fields widgets to show only the foreign key ID in dropdowns (making them pretty unusable).

It seems that `ModelAdmin.autocomplete_view` was an undocumented feature, so it's understandable that it was moved without explanation. Nevertheless, we're a bit stuck now. How can we choose which model field is used for the autocomplete_fields widgets in Django >=3.2?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9928e479-e689-4ae3-82c1-c8b39ce2af3cn%40googlegroups.com.

No comments:

Post a Comment