Recent Posts (Page 5)

Django Quiz 2023

This evening I held a quiz at the December London Django Meetup Group. The quiz is a regular tradition: this was the fifth quiz that I’ve presented, and the sixth overall.

Read more...

Django: Defer a model field by default

Some models have one or a few large fields that dominate their per-instance size. For example, take a minimal blog post model:

Read more...

Django: Fix version 5.0’s URLField.assume_scheme warnings

Since Django’s inception, the web has gradually moved from HTTP to HTTPS, a welcome move for security. But the history has meant older parts of Django have had a lingering HTTP bias. Many of these have been migrated to default to HTTPS instead in previous versions. Django 5.0 starts the migration of another, tiny HTTP bias in forms.URLField.

Read more...

Git: Enable denser git status output with --short or status.short

By default git status uses “long format”, which lists information explicitly. This format takes quite a lot of words and vertical space to split file status by section:

Read more...

Git: Undo a rebase with git reflog

If you make a mistake whilst rebasing, it might seem hard to undo. But with git reflog, you can find the original commit SHA and revert back to it. Let’s see how with an example.

Read more...

Django-related Deals for Black Friday and Cyber Monday 2023

Here are some Django-related deals for this year’s Black Friday (24th Nov) and Cyber Monday (27th Nov), including my own.

Read more...

Django: Stop a backgrounded runserver with lsof

If you start runserver but your terminal session gets closed, the server can continue running in the background. For example, this can happen when your IDE crashes. This situation is annoying because you can’t stop the backgrounded runserver with Ctrl-C.

Read more...

My appearance on The Python Show

Earlier this week, I made another podcast appearance on The Python Show, episode 22: Git and Django with Adam Johnson. As fellow authors, Mike and I talked a lot about the writing process, on topics like:

Read more...

My appearance on the PyBites Podcast

Last week, I made another podcast appearance on the PyBites Podcast, episode 139: Maximizing Your Developer Experience (DX) with Adam Johnson. We talked about various topics, including:

Read more...

My appearance on The Real Python Podcast 179

I had the pleasure of returning to The Real Python podcast in last week’s episode 179, Improving Your Git Developer Experience in Python. It was great to catch up with host Christopher Bailey and chat about:

Read more...

Django: Maybe disable PostgreSQL’s JIT to speed up many-joined queries

Here’s a write-up of an optimization I made in my client Silvr’s project. I ended up disabling a PostgreSQL feature called the JIT (Just-In-Time) compiler which was taking a long time for little benefit.

Read more...

Git: Show commits that come after

git log with a commit SHA shows that commit and those before it:

Read more...

GitHub Actions: Faster Python runs with cached virtual environments

Most projects I work on use Python, good ol’ Pip, and pip-tools. Below is a pattern I’ve used to speed up the GitHub Actions workflow runs on several such projects. On larger projects with many dependencies, it can save tens of seconds per run.

Read more...

Git: Force push safely with --force-with-lease and --force-if-includes

When you push, Git checks that you are only adding commits to the remote branch. If you try to push an out-of-date branch, it will fail:

Read more...

Git: Show a commit message or subject

To show only the subject of the latest commit (the first line of its message), use:

Read more...

Shell commands to copy to clipboard

The clipboard is an easy way to transfer data from the command line to other tools. Use your system’s “copy to clipboard” command to store a command’s output for pasting into other applications.

Read more...

Git: Rebase an old branch incrementally

You worked on a sizeable feature branch some time ago but left it to focus on other things. Now you’re ready to pick it up, so you want to rebase it onto your updated main branch. But when you try that, you’re presented with an overwhelming number of merge conflicts.

Read more...

Boost Your DX bundle deal

I released Boost Your Git DX nearly two weeks ago. It’s the second in my “Boost Your DX” series, following last year’s Boost Your Django DX. Both books aim to improve your development experience with their respective tool.

Read more...

“Boost Your Git DX” out now

My new book, Boost Your Git DX is out now, on my birthday 🥳. It’s taken nearly a year of work with four months in early access.

Read more...

Git: Show the initial (root) commit

To show the initial, or root, commit* of your repository, use:

Read more...

My fourth appearance on Django Chat

I’ve once more had the pleasure of joining Carlton and Will on the Django Chat podcast, in Episode #146. We spoke on Tuesday, just hours after Django 5.0 alpha 1 was released, on several topics:

Read more...

Git: Don’t create .gitkeep files, use .gitignore instead

Git only tracks files, not directories. It will only create a directory if it contains a tracked file. But sometimes you need to “track” a directory, to ensure it exists for fresh clones of a repository. For example, you might need an output directory called build.

Read more...

Django: Move a template tag library into builtins

Django’s template engine has an underappreciated builtins option that selects libraries to preload in every template. Making a library a builtin avoids the need for an explicit {% load %} tag whenever you use its tags or filters. Putting key libraries in builtins can shorten your templates and make development a little bit faster.

Read more...

Introducing flake8-logging

The Python standard library’s logging module is a go-to for adding observability to applications. Many tools also integrated with it or enhance its capabilities, such as structlog and Sentry.

Read more...

Git: Clear unreachable files from the .git directory

Every object you commit in Git is copied into its object store, within the .git directory. If you undo a commit, the commit object and associated file objects remain in Git’s object store, at least for a while. The normal garbage collection process will clean them out, by default in 30 days.

Read more...