Django

Python: Selenium with PhantomJs to capture Screenshots

PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG. And Selenium is A portable software-testing framework for web applications. Selenium provides a record/playback tool for authoring tests without the need to learn a test scripting language (Selenium IDE) Using the combination of selenium and PhantomJs can give you a way to capture screenshots and use it in your choices. For that let's install PhantomJs in your computer. For Ubuntu/Debian…

Keep reading

Documentation Of Django Encrypt File

Django Encrypt File is a simple Library which can be used to encrypt uploaded files and store them. Installation Use pip to install it: pip install djangoencryptfile Or pip install https://github.com/ruddra/django-encrypt-file/tarball/0.7 Basic Usage from djangoencryptfile import EncryptionService from django.core.files import File password = '1234' service = EncryptionService(raise_exception=False) open('readme.md', 'rb') as inputfile: usefile = File(inputfile, name='readme.md') encrypted_file = service.encrypt_file(useFile, password, extension='enc') # it will save readme.md.enc decrypt_file = service.decrypt_file(encrypted_…

Keep reading

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

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 a Blog using Django Part 2

From previous post, you have configured and ran django, also added admin site to the django. To view the working source of this tutorial, check here at: https://github.com/ruddra/myblog Now click on the myblog section and click add to add new blog, which will look like this: You can create new tags using Tags section of the admin page or clicking the (+) button right beside the Tags section on the new blog creation page, marked with blue circle in the previous image. After successfully adding a new…

Keep reading