Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
872 มุมมอง

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.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ต.ค. 23
2169
5
มี.ค. 22
14863
list view with additem inside notebook แก้ไขแล้ว
1
ก.พ. 16
5765
0
มี.ค. 15
3860
4
ม.ค. 24
23179