I want to export the results I have in a Queryset that I obtain from a haystack search view. In order to do this, I've found the best way is by doing it asyncronally, so I'm using Celery and Rabbitmq to manage the task and there create the file and iterate over all the results and then notify the user via email that the file is ready for them to grab it. However, in order to pass Celery the QuerySet, I need to serialize it.
Is there a quick way to do this? Or should I copy the request parameters and redo the search?
You can serialize the Haystack QuerySet to JSON like this:
from django.core import serializers
serializers.serialize("json", [q.object for q in queryset])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With