#5863: list_display does not allow functions of referenced objects -------------------------------------+------------------------------------- Reporter: Beat Bolli | Owner: nobody <me+django@…> | Status: closed Type: Uncategorized | Version: master Component: contrib.admin | Resolution: wontfix Severity: Normal | Triage Stage: Design Keywords: list_display | decision needed Has patch: 1 | Needs documentation: 1 Needs tests: 0 | Patch needs improvement: 1 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by jcushman):
* ui_ux: => 0 Comment: If anyone else who wants to be able to refer to foreign keys with underscore syntax in list_display comes across this ticket, I put together a subclass of ModelAdmin to do that: http://djangosnippets.org/snippets/2887/ So you can just do: {{{ class FooAdmin(RelatedFieldAdmin): list_display = ('address__phone','address__country__country_code') }}} and it figures it out. The benefit of using a subclass over luke's suggestion is we can override queryset() to automatically add the related models to select_related(), which prevents a database hit for each row. It also sets sensible defaults for short_description and admin_order_field. Would love to hear (over at djangosnippets) if anyone has suggested improvements. -- Ticket URL: <https://code.djangoproject.com/ticket/5863#comment:42> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.