Skip to content

Async Task with django-celery and rabbitmq. Optimization with select_related and prefetch related.

Notifications You must be signed in to change notification settings

pratibhajagnere/django-celery-example

 
 

Repository files navigation

Django Examples

Repository contains basic example of how to use django-celery to run Async task. It is a basic posts application which also includes good example of how to use mixins.

  • Send email on User registration using rabbitmq and django-celery.
  • Optimize Number of queries using select_related and prefetch_related.
  • Create custom middleware to log every query being generated by Django ORM layer.
  • Create get,post,put API quickly with model mixins.
  • example for Class based paginatinos.

Setup steps:

  • Create virtualenv : virtualenv venv
  • Activate virtualenv : source venv/bin/activate
  • install required packages :sudo apt-get install postgresql postgresql-contrib postgresql-client python-dev libpq-dev python-psycopg2 git python-virtualenv
  • pip install -r requirements.txt
  • Install postgres and create database named posts_app
  • migrate : python manage.py migrate
  • python manage.py runserver

please consider adding settings_local.py in your local when you clone this repo. add following settings to setup Email functionality.

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '********@gmail.com'
EMAIL_HOST_PASSWORD = '*****'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
EMAIL_PORT = 587
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

About

Async Task with django-celery and rabbitmq. Optimization with select_related and prefetch related.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.7%
  • HTML 3.3%