I have a complicated query built up based on a users profile, I start with
qset = Profile.objects
bunch of stuff that works to return me profile objects (it uses Q objects, and optionally ignores some fields if they were left blank)
I could grab the users with selected_related()
but that still leaves me with a list of profiles, rather than a list of users.
Because of the way my templates are set up for other things, I'd really like to have a list of users
{% for user in users %}
How can I convert his queryset for Profile objects into one for Users.
Currently I use:
profile_userids = list(qset.values('user_id'))
user_ids = [d['user_id'] for d in profile_userids]
users = User.objects.in_bulk(user_ids)
which results in 2 queries, and the conversion of all the user_id's into python objects.
How can I use the queryset that I have generated on the Profiles object to select users?