Re: Display labels for autocomplete fields

2019-08-11 Thread bjw
Actually, I can think of occasions where what is displayed would vary depending 
on which model the FK was from,  not only on the model that is the target.

bjw 

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/c05cce80-dd59-497e-a6b1-606cfbfa58bf%40googlegroups.com.


Display labels for autocomplete fields

2019-08-06 Thread bjw
At present the admin autocomplete docs mention 
`ModelAdmin.autocomplete_fields` and
`ModelAdmin.search_fields` which are used to configure select2. There are 
also options for overriding the queryset used.

However there seems to be no way of specifyng what is shown in the 
autocomplete... it just calls `__str__` on the objects returned.

Would it be possible to add a `search_display_fields` on the relevant 
ModelAdmin, alongside `search_fields` to customise the display in the form 
select box? This could be either a model field or a callable on the model 
or modeladmin.

Cheers!

bjw

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/8b785f3f-4158-4a7d-8f9a-41f82995671f%40googlegroups.com.