Docker: Use Celery in Django(Redis as Broker)

In previous two posts, we have deployed Django with Postgres, Nginx, now its time to do some async stuff using Celery. In this post, I will do the magic tricks first, explain them later. Add Celery to Django To add celery, we need make a container for celery. We can re-use the Dockerfile of django for making celery's container like this: FROM python:latest ENV PYTHONUNBUFFERED 1 #ENV C_FORCE_ROOT true # intentionally kept it commented ENV APP_USER user ENV APP_ROOT /src RUN groupadd -r ${APP_USER} \ &…

Keep reading

Serve Static Files by Nginx from Django using Docker

This is more of a followup post of my previous blog. Before I start, I am assuming you have successfully deployed django using docker & nginx, but having some problems serving static files. No worries, its easy. Just follow these steps: 1. In your django settings.py file, add static file directory i.e. STATIC_ROOT=/static. So what it will do is, when you run collectstatic command(python manage.py collectstatic), it will store the static files in your /static directory of OS. 2. Now in docker-compose.yml folder,…

Keep reading

Deploy Django, Gunicorn, NGINX, Postgresql using Docker

This post mainly based on this blog: https://docs.docker.com/compose/django/. I will be extending this post by serving django+gunicorn using Nginx, also I will using Postgresql docker container to use it as database. Lets not waste time and go to the following steps. 1. Let's make an empty directory named myproject and add another folder inside name it src. src should contain the django project. For testing purpose lets put a simple django project inside named mydjango. 2. Let's create a subdirectory inside myproject and name…

Keep reading

Make OSX Notifications From RSS Feed Using Python

Today we are going to see how make OSX notifications from RSS Feed of any website using Python. So first of all, let us see how to make a simple notification. We are going to use AppleScript for this. Go to terminal and Type: >>osascript -e 'display notification "Lorem ipsum dolor sit amet" with title "Title"' We shall see a notification popping up in right up corner like this: Now, we will use this command to pop up notifications using python from rss feeds. Now, we are…

Keep reading

Make .CSV file using MySQL and Python

In this blog, I am going to show how to develop an application by which we can make .csv files from MySQL database using Python. Now, let us start by getting data from Database. Lets say we have a DB names csv_test and it contains a table named test with fields id and name, and for testing purpose let us have some values inserted into it like this: +------+--------+ | id | name | +------+--------+ | 1 | test_1 | | 2 | test_2 | | 3 | test_3 | +------+--------+ Now, to get all…

Keep reading