iommirocks / iommi

Your first pick for a django power cord
http://iommi.rocks
BSD 3-Clause "New" or "Revised" License
804 stars 51 forks source link

Table use query with multiple objects #513

Closed deepaktrama closed 7 months ago

deepaktrama commented 9 months ago

Can the table use fields from multiple related models like display album.artist.name and is there an example of this in the docs?

Thank you.

boxed commented 9 months ago

Yes, do this: auto__include=['album__artist__name'] for example.

deepaktrama commented 9 months ago

yes, I confirm that the above works! is it possible to run a function or python operation to beautify the string for example below.

autoinclude=['albumartistname[0:3]'] # python slice to get first 3 characters autoinclude=['beautify(albumartistname)'] # custom function

I understand that you are replacing the . operator with __, are there some docs on this convention and practice?

boxed commented 9 months ago

You want to specify a cell formatter. https://docs.iommi.rocks/en/latest/cookbook_tables.html#how-do-i-customize-the-rendering-of-a-table

And for the dunder stuff maybe https://docs.iommi.rocks/en/latest/philosophy.html