I’m trying to retrieve the following data in a view:
user_profile has a one-to-one join to users
user_profile has a many-to-many join to store, via the stores field
store has a one-to-many join to targets, via targets.store
I can retrieve all stores associated with a user by doing:
user_profile = request.user.get_profile()
all_stores = user_profile.stores.all()
What I’d like to retrieve is all targets associated with the user ID of user_profile, presumably via the all_stores result, but I’m not sure how to get there.
1 Answer