How can a Celery task have access to the Django database-abstraction API? Does this need to be coded from scratch using one of the strategies for stand-alone Django ORM usage, or is there a more streamlined, built-in way or common practice?
It seems that nobody is asking this question. However, to me, it's fundamental.
This example implies that it's no big deal, but can someone explain how the session management and ORM scoping works between Celery and Django?
By default Celery pickles its task parameters. Django model instances can be pickled too.
The catch is that pickling a model instance is like taking a snapshot of it at that time. Unpickling doesn't touch the database.
Whether this is good or bad depends, I suppose, on your needs. I tend to send a primary key into my tasks and re-query for the object in question.
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