1👍
✅
The field name to refer to should be defined in your ‘models.py’ file – it’s not clear whether you are confident i.name or i.book_name are already defined or if you are guessing. It’s the column name in the source table in the database. If its actually b_name or title or something, you will need to use that specifically.
The other thing is that you might need quotes around strings in the label list, and possibly the built-in template tag ‘escapejs‘ if there are any special characters that might cause problems in a quote-delimited string.
so try something like (title is just my guess):
labels: [{% for i in book %}'{{ i.title|escapejs }}',{% endfor %}]
Source:stackexchange.com