I'm using Celery quite effectively with Django as many are. It's just awesome for running time consuming background tasks, and providing progress bar updates to a web page. Love it.
Now I would like a celery task to do some form processing. That is in a Django view, where I have access to the form (or formset) that's just been submitted, with all its data (in
form.request.POST) and methods (like form.save() which saves it to the database as a Django object or objects (in the case of a formset).
Of course anything we pass to a Celery task must be serialized (as it's passed through the broker) and there is plenty of help around on serializing Django data objects but I can't find diddly squat on serialzing forms and every effort I've tried, JSON, pickle, dill, all fails.
I can serialize the POST data of course, and that great but I can't see how the Celery task can then re-instantiate a form object from that.
I wonder if anyone has any experience to share here. Essentially I see two possible solutions:
- Serialize the form or formsets somehow. Anything better than dill out there that might?
- Serialize some part of the form or formsets (eg the POST data) and re-instantiate a form or formset at the other end using it.
Either approach would work, 1. would seem less hassle if it has a solution, and 2. seems more likely to provide one to me right now.
Kind regards,
Bernd.