View Single Post
Old 04-14-2023, 10:02 AM   #576
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,489
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Levinas2021 View Post
Hi everyone,

I'm having trouble with adding code to the "model" field (column Ranking Position) in my application.
I've tried adding the code to the field, but it keeps giving me an error.
I'm not sure what I'm doing wrong.

I've attached some screenshots to show what I've tried.
When I test the function in the "Edit Model" option, it works fine and returns the value "1" (Screenshot 1).
However, when I try to use it in the "model" field for the column Ranking Position, it returns an error (Screenshots 2 and 3).

Can anyone help me understand what I'm doing wrong and how I can successfully add my code to the "model" field?
I would greatly appreciate any guidance or suggestions.

Thank you!
The error tells you that the book_values() function can't be used in a composite column. See https://www.mobileread.com/forums/sh...35#post4235735 for how to get around this.

The problem is that those functions can be slow. Since you are writing in Python you would be better served using the calibre database API, which is much faster. Glancing at your template I think you want
Code:
context.db.new_api.get_custom_book_data('#ranking')
chaley is offline   Reply With Quote