Skip to content

Latest commit

 

History

History
 
 

celery-async-tasks

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Asynchronous Tasks with Django and Celery

Example project for integrating Celery and Redis into a Django application. This repository holds the code for the Real Python Asynchronous Tasks With Django and Celery tutorial.

Setup (macOS)

To try the project, set up a virtual environment and install the listed dependencies:

$ python -m venv venv
$ source venv/bin/activate
(venv) $ python -m pip install -r requirements.txt

You'll also need to install Redis on your system:

$ brew install redis

Once you've installed all the dependencies, you need to start three processes that need to run at the same time:

  1. Django
  2. Redis
  3. Celery

To get all of them running, open three different terminal windows and start them one-by-one:

Django app:

(venv) $ python manage.py migrate
(venv) $ python manage.py runserver

Redis server:

$ redis-server

Celery:

(venv) $ python -m celery -A django_celery worker -l info

When all three processes are running, you can go to localhost:8000/ and submit a feedback response. Celery will simulate a work-intensive process and send an email at the end of it. You'll see the email message show up in the log stream on the terminal window where the Celery worker is running.