Let’s say I have a Django app
users. The admin menu shows this as category
Users. That’s ok, but if the website users speak another language I want this name translated. Also I’m not necessarily using
Users as name in the admin menu as section name, but can use something more descriptive.
Website Users, as example.
The Django Web Framework makes it quite easy to add new referenced objects in the admin menu.
A simple task, or so I thought: in a Jinja template keep track of the number of items in a loop. And then use that count afterwards.
Disclaimer: the number of items is not equal the number of times the loop runs, so I can’t use the loop variables.
Turns out that Jinja has other opinions, and variables inside a loop are all local. When a variable is changed inside the loop, the scope of the variable stays local, and once the loop ends the original value of the variable is restored. That’s even true for variables which are created outside the loop.
Installing a new Raspberry Pi is always the same few steps, and still I have to look them up almost every time. Here is the summary.
In one of my Ansible Playbooks I’m updating Let’s Encrypt certificates. Because the Playbook is rather long, I want to make sure that Ansible is not spending cycles on a certificate which is not about to expire. Hence I wrote a small filter plugin, which receives the certificate path and the number of days the certificate must be still valid.
This plugin is used to filter out any “good” certificate which does not need to be updated.
If you use pure PHP (no database abstraction layer) with PostgreSQL, you may run into the problem that your
BOOLEAN columns are not recognized by PHP but the value is instead returned as a string.