跳至内容
菜单
此问题已终结
2 回复
703 查看

Hi, 

I am trying to display the book's author name in a list view. I added <field name="author.name" /> inside the <list> tag, but I get this error:
Field "author.name" does not exist in model "book"


How can I fix this?

Models:

  author

​- name


  book 

​- author


I fixed this creating a compute field called author_name and resolve it in model file. I did this, but I would like to know wheather there is someway more simple (like Django)


形象
丢弃
最佳答案

Creating a related field in the book model with stored=True, or a calculated field the way you're doing is good. Because sometimes you need to search and filter by the author. And there maybe more than 1 author for a book. Normally for display purpose, I think sometimes we just add the author to the list view (and the name will automatically be shown with a link to that author. 

形象
丢弃
编写者 最佳答案

Thanks!

It worked fine.

形象
丢弃
相关帖文 回复 查看 活动
0
10月 23
2023
5
3月 22
14596
1
2月 16
5658
0
3月 15
3714
4
1月 24
22953