Skip to content

Instantly share code, notes, and snippets.

@PraneethKarnena
Last active November 9, 2020 02:56
Show Gist options
  • Save PraneethKarnena/3e42186b0764d28ee5bebe1e59327e46 to your computer and use it in GitHub Desktop.
Save PraneethKarnena/3e42186b0764d28ee5bebe1e59327e46 to your computer and use it in GitHub Desktop.
Celery Installation & Configuration For Django
# Installation - Celery 4.4.7
pip install celery
pip install django-celery-beat
pip install django-celery-results
# <project-folder>/__init__.py
from .celery import app as celery_app
__all__ = ('celery_app',)
# <project-folder>/celery.py
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
app = Celery('project')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
@app.task(bind=True)
def debug_task(self):
print(f'Request: {self.request!r}')
# settings.py
CELERY_BROKER_URL = f'pyamqp://guest:guest@localhost'
CELERY_RESULT_BACKEND = 'django-db'
CELERY_TRACK_STARTED = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment