The Django Celery Redis github repo shows a full Django project leveraging the results of this blog post tutorial and this sample project.
git clone https://github.com/codingforentrepreneurs/Django-Celery-Redis
cd Django-Celery-Redismacos/linux
python3 -m venv venv
source venv/bin/activate
windows
c:\Python311\python.exe -m venv venv
.\venv\Scripts\activate
Install requirements
python -m pip install pip --upgrade
python -m pip install -r requirements.txtRun a local redis instance via Docker Compose
docker compose -f compose.yaml up -dThis will give us redis://localhost:6170
Create .env in src/.env with:
CELERY_BROKER_REDIS_URL="redis://localhost:6170"
DEBUG=TrueNavigate into your Django root:
cd src/
lsYou should see at least cfehome/ and manage.py.
Run your project in 2 terminals:
python manage.py runservercelery -A cfehome worker --beat
Verify it's working:
python manage.py shellthen import placeholder tasks
from movies.tasks import add
add.delay(1,3)The result should be printed in the celery -A cfehome worker --beat terminal.