django-planet

Blog: Adam Johnson

web https://adamj.eu/
Author Adam Johnson

Django: Introducing django-harlequin, a launcher for Terminal-based SQL IDE Harlequin

May 6, 2024 » Adam Johnson » [Archived Version]

Harlequin is a Terminal-based SQL IDE by Ted Conbeer. It is pretty popular, with over 2,500 GitHub Stars and counting. It looks like this: Harlequin is built with Textual to give a very interactive experience on the terminal. You can click around its UI and use keyboard shortcuts. I …

Read More

Django: An admin extension to prevent state leaking between requests

April 28, 2024 » Adam Johnson » [Archived Version]

Here’s a small protection I added to a project a few years ago. I was considering it again since I saw a similar potential bug in a Django middleware. Long live the ModelAdmin instances Django’s admin site is configured by the ModelAdmin class. You register this per model …

Read More

Python: Diffing unit tests to keep a copy-pasted code in sync

April 25, 2024 » Adam Johnson » [Archived Version]

Copy-paste-tweaking library code feels like a dirty but inevitable programming practice. Often driven by deadlines or other constraints, it seems all projects end up with something copy-pasted in and tweaked for one specific use case. When we find ourselves doing this, it’s essential to consider the long-term maintenance of …

Read More

Python: Make line number paths with inspect

April 24, 2024 » Adam Johnson » [Archived Version]

Many terminals and text editors support what I’ll call “line number paths” of the form <filename>:<lineno>. Opening that path, whether by clicking or passing to a CLI, opens the given file at that line. Python’s inspect module has a couple of functions that can be combined to …

Read More

Django: Pinpoint upstream changes with Git

April 23, 2024 » Adam Johnson » [Archived Version]

Django’s release notes are extensive and describe nearly all changes. Still, when upgrading between Django versions, you may encounter behaviour changes that are hard to relate to any particular release note. To understand whether a change is expected or a regression, you can use Django’s Git repository to …

Read More

Django: Write-up on optimizing the system check framework

March 23, 2024 » Adam Johnson » [Archived Version]

Django’s system check framework provides fantastic protection for configuration mishaps. It’s like a targeted linter that runs when you start Django commands. It takes advantage of runtime setup to inspect the true state rather than infer it from the source. I love the system check framework: I have …

Read More

Django: Fuss-free use of Homebrew GDAL/GEOS libraries on macOS

March 20, 2024 » Adam Johnson » [Archived Version]

GeoDjango requires the GDAL and GEOS spatial libraries. On macOS, you can use Homebrew to install these, but they won’t be picked up by default since they live in a non-default library directory, /opt/homebrew/lib. Django will fail to start with an exception: Traceback (most recent call last …

Read More

Django: Join the community on Mastodon

Feb. 10, 2024 » Adam Johnson » [Archived Version]

Mastodon is a Twitter-like social network with a solid Django community presence. It’s a fantastic online arena for connecting with others, discovering news, discussing issues, and sharing FOMO-inducing conference photos. Historically, Twitter was the primary social network for the Django community, as for much of tech. But since Elon …

Read More

pre-commit: Block files based on name with a custom “fail” hook

Jan. 24, 2024 » Adam Johnson » [Archived Version]

This post is an adapted extract from my book Boost Your Django DX, as updated last week. pre-commit’s “fail” virtual language fails all files that it matches. Combine it with pre-commit’s file name and type matching to block unwanted files in your repository. Let’s try it out …

Read More

Boost Your Django DX update out now

Jan. 17, 2024 » Adam Johnson » [Archived Version]

I just released a major update to my 2021 book Boost Your Django DX. This update contains new content, a bunch of edits, and uses the latest versions of tools, including Python 3.12 and Django 5.0. Boost Your Django DX contains many recommendations to improve your development experience …

Read More