Using Celery with Django
We have learned about the Django and DRF features that are provided out of the box in our previous chapters. Django and DRF both provide a scope of customization and extendibility to the framework, but async programming has been missing from Django for quite some time. However, with the introduction of Django 4, Django has started to natively support async programming using different async interfaces. This still doesn’t help with requirements to execute long-running jobs or jobs executed at periodic intervals. To address this requirement, we use a well-known third-party package in Python, Celery.
Celery is a simple, flexible, and reliable distributed system used to process vast amounts of messages. It is a task queue with focus on real-time processing while also supporting task scheduling. In this chapter, we shall learn how to set up Celery with Django and use celery beat to perform periodic tasks in Django. Since Celery itself is an altogether different...