#5863: list_display does not allow functions of referenced objects -------------------------------------+------------------------------------- Reporter: Beat | Owner: nobody Bolli <me+django@…> | Status: closed Type: | Component: contrib.admin Uncategorized | Severity: Normal Milestone: | Keywords: list_display Version: SVN | Has patch: 1 Resolution: wontfix | Needs tests: 0 Triage Stage: Design | Easy pickings: 0 decision needed | Needs documentation: 1 | Patch needs improvement: 1 | -------------------------------------+-------------------------------------
Comment (by lukeplant): Also, in response to andybak and anonymous, please note: list_display is fundamentally different from list_filter and search_fields. The other two are defining operations that must happen in the database, whereas list_display is defining an operation that must happen in Python code, and refers to Python functions/methods, and **not** to database fields. The confusion is that a name that of a database field is also the name of the corresponding attribute on the Python object, but that is where the similarity ends. So, for instance, you can set `'__unicode__'` in list_display, and it will refer to the `__unicode__` method, and not attempt any field lookups, despite the presence of double underscores. As it happens, this example makes it obvious that we cannot sensibly add the feature as proposed - how would you refer to the `__unicode__` method on a related object? `'foreign_key____unicode__'`? How would you parse that? What about other methods that people might choose to define, like `__html__`, etc.? The only way this feature could get in is we are happy with a bunch of special cases in the implementation, and a bunch of arbitrary limitations in functionality. -- Ticket URL: <http://code.djangoproject.com/ticket/5863#comment:37> 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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.