Tech News
← Back to articles

A first look at Django's new background tasks

read original related products more articles

Django 6.0 introduces a built-in background tasks framework in django.tasks . But don't expect to phase out Celery, Huey or other preferred solutions just yet.

The release notes are quite clear on this:

Django handles task creation and queuing, but does not provide a worker mechanism to run tasks. Execution must be managed by external infrastructure, such as a separate process or service.

The main purpose of the new django.tasks module is to provide a common API for task queues implementations. Jake Howard is the driving force behind this enhancement. Check out the introduction on the Django forum.

His reference implementation, and simultaneously a backport for earlier versions of Django, is available as django-tasks on GitHub.

But let's ignore that and play with the more minimal version included in Django 6.0 instead. By creating our very own backend and worker.

Our project: notifications

We're going to create an app to send notifications to phones and other devices using ntfy.sh. (I'm a fan!)

If you prefer to dive into the code yourself, check out the final version of the project on GitHub.

All that's required to send a notification to your phone using nfty is:

... continue reading