Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
845 Lượt xem

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)


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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. 

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thanks!

It worked fine.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 10 23
2151
5
thg 3 22
14842
1
thg 2 16
5754
0
thg 3 15
3849
4
thg 1 24
23170