Jinja template Inheritance using Database

Jinja is a web template engine for the Python programming language. A Jinja template is simply a text file and can generate any text-based format (HTML, XML, CSV, LaTeX, etc.). A template contains variables and/or expressions, which get replaced with values when the template is rendered, thus serving dynamic content. Commonly, templates are stored as files, either in git-repo or s3 buckets. Depending on your use case, you can store the templates in the database as well....

July 31, 2020 · 2 min · wilspi

Log requests and responses with Django Middleware

From Django’s context: Middleware is a framework of hooks into Django’s request/response processing. It’s a light, low-level “plugin” system for globally altering Django’s input or output. Middleware is like a layer which processes every request and response. Instead of logging requests and responses in resp. views, its better to do at middleware layer which will log every incoming request. Why better? it will log unhandled requests/views one time job, no need to configure for every request/view Here, we are using Django’s middleware semantics to construct a middleware which will log all requests and corresponding responses....

July 29, 2020 · 2 min · wilspi

Nix Recipe: Setup Python

This is a nix recipe for building and running python in a virtual nix environment. Create shell.nix with following: let nixpkgs = import (builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/20.03.tar.gz) { overlays = []; config = {}; }; in with nixpkgs; stdenv.mkDerivation { name = "python-env"; nativeBuildInputs = [ zsh vim python37 python37Packages.pip python37Packages.virtualenv ]; # ENV variables PROJDIR = "${toString ./.}"; # Post Shell Hook shellHook = '' echo "Using ${python37.name}" [ !...

March 9, 2020 · 1 min · wilspi