How to Create SECRET_KEY for Django Settings

When you start a django project, django-admin startproject automatically adds a randomly-generated SECRET_KEY to each new project. However if you want to change it, or add a seperate one to each of your environment, e.g: one for ‘production’, one for ‘staging’, one for ‘production’ etc, how do you gerenerate a new ones? There would be another case: you cloned a project from a remote repo and want to change the default SECRET_KEY.
Read more →

How to Set Permanently $PATH on Linux/Unix

You’re trying to add a directory to your $PATH so it will always be in your linux $PATH and accessible anywhere. You can add your ‘path’ to $PATH with below command: $ export PATH=$PATH:/path/to/dir However each time you exit the terminal or start a new terminal instance, or reboot the system this path is lost and you need to run the export command again. To set it permanently follow one of the two below:
Read more →

How to Use UUID as a Primary ID in Django Models

Intro In Django whenever we create any new model, there is an ID-or PK, model field attached to it. The ID field’s data type is integer by default. To make this integer id field UUID, we can use UUIDField model field, which was added in Django 1.8. UUID A universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems. They are commonly represented as 32 hexadecimal characters separated by four hyphens.
Read more →

How to Install Python 3.8 on Ubuntu

This brief tutorial shows how to install and configure Python 3.8 on Ubuntu. There are 2 methods to install python on Ubuntu. I prefer first method and strongly recommend that but it depends on developer’s taste. Method 1: Install It From Source Code I prefer this method since I’d rather always go to source, whether it is documentation for an API or installing something. Out of the box default python version for Ubuntu 18.
Read more →

What does if __name__ == “main” do in Python?

An introduction to the name variable You probably seen the name variable if you’ve gone through some python open source code. For instance below: #!/usr/bin/env python3 # -- coding: utf-8 -- import logging import os from logging import FileHandler from logging import Formatter from flask import Flask from flask import render_template from flask import request from forms import * app = Flask(name) app.config.from_object("config") @app.route("/") def index(): return render_template("index.html") @app.route("/login") def login(): form = LoginForm(request.
Read more →