I am filtering userprofiles via their interests using Haystack. How can I use Haystack's result to query a model to return me all selected users belonging to these userprofiles?
Right now I am doing it the following way, but it is really slow, as haystack_results can be a list of many thousands of entries:
haystack_results = SearchQuerySet().raw_search('coffee AND django_ct:common.profile').values_list('pk', flat=True)
User.objects.filter(profile__id__in=haystack_results)
User and Profile have a OneToOne Relationship:
class Profile(models.Model):
user = models.OneToOneField(...)
Do you know any better way?
Thanks for your help, Matthias