Django: hide the development server warning
From Django 5.2 (April 2025), the runserver management command outputs a warning:
From Django 5.2 (April 2025), the runserver management command outputs a warning:
I recently released a new package called inline-snapshot-django. It’s a tool for snapshot testing SQL queries in Django projects, described shortly.
A neat testing pattern is writing common tests in a base class and then applying them to multiple objects through subclassing. Doing so can help you test smarter and cover more code with less boilerplate.
Python comes with two built-in profilers for measuring the performance of your code: cProfile and profile. They have the same API, but cProfile is a C extension, while profile is implemented in Python. You nearly always want to use cProfile, as it’s faster and doesn’t skew measurements as much.
Git supports storing symbolic links (symlinks) in your repository, which are filesystem links that point to another file or directory. These are great for when you want to have the same file at multiple locations in your repository, such as some configuration file that is used for multiple sub-projects. But how can you list all the symlinks in your repository?
on: [push, pull_request]I’ve often seen a GitHub Actions workflow defined with a trigger like:
On a client project today, I noticed that running docker exec -it tacks this advert on the end of the output:
pre-commit is my favourite Git-integrated “run things on commit” tool. It acts as a kind of package manager, installing tools as necessary from their Git repositories. This makes it fairly easy to set up: all you need to install is pre-commit itself, and it takes things from there.
You may encounter this warning when cloning a Git repository:
version keys from Compose filesIf you use Docker Compose, you may see this message:
Adam Hill posted a question on Mastodon: he wants a model field that uses choices that doesn’t generate a database migration when the choices change. This post presents my answer. First, we’ll recap Django’s default behaviour with choice fields, a solution with callable choices, and the drawbacks.
In Python, a mixin class is a class that is not intended to be used directly, but instead “mixed in” to other classes through multiple inheritance. Mixins are not really a language feature but more of a conventional pattern allowed by Python’s multiple inheritance rules. Unfortunately, adding type hints to mixin classes can be tricky because they implicitly require subclasses to fit a certain shape.
GitHub-Flavored Markdown (GFM) is GitHub’s variant of Markdown, with extra features like task lists and alert boxes. It’s used in issues, pull requests, comments, and many other places on GitHub.
Django 5.2 was released last Wednesday, another exciting step forward for our favourite web framework. It comes with a composite of new features, contributed to by many, some of which I am happy to have helped with. Below is my pick of highlights from the release notes.
Do you see this message when you open a new terminal session?
Last week, I released the second update to my book Boost Your Git DX. Today I’m happy to announce that I have released a free sample of the book.
Today I have released the second update to Boost Your Git DX, my book of developer experience (DX) recommendations for using Git. Since the last update (2024-04-04), it has grown again by 28 pages, for a new total of 391 pages!
hyperfine is a neat tool for benchmarking commands. If you provide it multiple commands, its output includes a comparison, saying which is the fastest, and by how much.
Some Python packages require native libraries to be installed on your system when you install them. For example, mysqlclient requires libssl and libcrypto. If those libraries are missing at install time, clang, the C compiler, fails with a message like:
JavaScript’s import statement lets module scripts import objects from other scripts. For example, you can define a script as a module in HTML:
Browser extensions can run JavaScript within the content of your tabs. This means they can trigger messages that appear in the devtools console. For example, one extension I use logs this warning on every tab:
You might see this message when running pytest on your Django project:
unittest.mockA few days ago, I blogged about debugging unraisable exceptions with Rich. Here’s a sequel on testing that some block of code doesn’t trigger any unraisable exceptions.
color.ui or --colorBy default, Git only colourizes in its output when writing to an interactive terminal. Sometimes, this heuristic isn’t accurate, for example, when you’re piping Git output through another command. In such cases, you can force colourization on or off with either the color.ui configuration option or the --color option. Let’s look at both in turn.
Take this Python class: