How to make a light query for a many to many relationship?
Users has many Lists
the ListUser
is the model that links them
Currently I'm doing like this but there are a lot of get queries to get all this data.
lists = []
for list in user.lists:
lists.append(list.list)
Now I got this:
list_users = user.lists.fetch(1000)
# problem is here: "list.list" will retrive data from database, but I just want that list's key, how to do?
list_keys = [list.list for list in list_users]
lists = List.get_by_key_name(list_keys)