Celery and Rabbitmq in Django And Monitoring with Flower, Just Couple of Steps to Get Async Working

Sajjad Hassanzadeh
Jul 27 · 4 min read

What do we need?

install RabbitMQ :

apt-get install rabbitmq-server
pip install Django
pip install celery

Djangocelery project

djangocelery/|-- app/|    |-- migrations/|    |-- __init__.py|    |-- admin.py|    |-- apps.py|    |-- models.py|    |-- tests.py|    +-- views.py|-- djangocelery/|    |-- __init__.py|    |-- settings.py|    |-- urls.py|    +-- wsgi.py|-- manage.py+-- requirements.txt


CELERY_BROKER_URL = ‘amqp://localhost’

Add Celery to your Django Project

|-- djangocelery/|    |-- __init__.py|    |-- celery.py|    |-- settings.py|    |-- urls.py|    +-- wsgi.py

Edit the __init__.py

|-- djangocelery/|    |-- __init__.py

Creating First Celery Task

Starting The Worker Process

celery -A djangocelery worker -l info
celery worker information
Received Tasks
Tasks Done

Monitoring Celery Workers

install Flower

pip install flower
celery -A djangocelery worker -l info
celery -A djangocelery flower
flower connection
flower dashboard
flower tasks
flower task details

In addition :

celery -A proj purge

Sajjad Hassanzadeh

Written by

Web developer in Django and Python. #SOReady2Help!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade