Recent Posts (Page 10)

Mike Acton’s Expectations of Professional Software Engineers

In a 2019 talk/rant titled “Everyone Watching This Is Fired”, games industry veteran Mike Acton rattled off a sample of 50 things he expects of developers he works with. The title refers to his tongue-in-cheek suggestion that anyone who doesn’t meet all these requirements would be immediately fired.

Read more...

How to clean up unused code with Git

Projects often accumulate an amount of unused code. This cruft makes a prjoect harder to navigate, and can confuse future development or debugging.

Read more...

Django: how to be a teapot

HTCPCP, or Hyper Text Coffee Pot Control Protocol, was published as an April Fool’s joke 24 years ago today. It’s an HTTP extension for controlling coffee pots, and whilst it is a joke, it appears in various places around the web.

Read more...

Django: Raise an error for missing template variables

It’s all too easy to forget to pass a variable to your template or make a typo in a variable name. Unfortunately, it can be quite hard to debug such mistakes, since Django’s default behaviour is to ignore the problem and render an empty string.

Read more...

You probably don’t need Django’s get_user_model()

Django’s authentication system, django.contrib.auth, provides a built-in User model class. You can swap this to a different class with the AUTH_USER_MODEL setting, most easily at the start of the project.

Read more...

JavaScript: lock your project’s Node.js version

It’s a good idea to ensure your project uses the same Node.js version in all environments. This way you can be sure that your code will work as expected, from development to production.

Read more...

Git: Squash and rebase a branch with --keep-base

When you have a long-lived feature branch with many “work in progress“ commits, it can become tiresome to rebase it onto your main branch due to conflicts. You can end up fixing conflicts in the same areas of the same files over and over for multiple commits.

Read more...

Git: Run a command on all files in a repository

Occasionally it’s useful to run commands on all files in your repository, or those matching a pattern. This is possible by combining git ls-files and xargs.

Read more...

django-htmx Now on Read the Docs

I’ve just released django-htmx 1.9.0. As part of this release, it now has a documentation site built with Sphinx, hosted on Read the Docs at django-htmx.readthedocs.io.

Read more...

Announcing WhiteNoise 6

WhiteNoise is a simple solution to serving static assets. It lets you skip configuring a separate web server for your static assets, and serve them straight from Django. It’s a brilliant tool. I’ve used it for years on various projects, and I’ve recommended it many times, and mentioned it in several blog posts.

Read more...

Appearance on Podcast.__init__

I joined host Tobias Macey on Podcast.__init__, in Episode 349, published this monday. The episode is titled “Improve Your Productivity By Investing In Developer Experience Design For Your Projects”. We covered various topics related to “developer experience” and general ways to improve it on any Python project.

Read more...

Django: serve source maps with contrib.staticfiles

Source maps are files that map your minified CSS or JavaScript back to the original code. They allow you to use your browser’s development tools to debug minified code as if it were the original. Also some error capture tools, such as Sentry, can use source maps to report errors for the original code.

Read more...

A Problem with Duplicated Mutable Constants

Here’s a small problem I’ve seen where several modules share versions of the same “constant” variable. It came up in the context of a Django project with multiple settings files, but it could happen in different contexts.

Read more...

Optimize your PNGs with oxipng and pre-commit

PNGs can be losslessly optimized to reduce their file size, by picking a better compression algorithm for the given image. The savings can be significant, like 50% (especially for macOS screenshots). This is an easy way to make web sites load faster.

Read more...

On Receiving the Malcolm Tredinnick Award

In December I was awarded the Malcolm Tredinnick Award. This is an annual award, selected by nominations from anyone in the Django community. I’m incredibly honoured to have been selected, joining a fine list of past recipients. I’ve been inspired by every one of them.

Read more...

How to Add a Favicon to Your Django Site

Your site’s favicon appears in the browser tab, and is a key way to brand your site. Setting up a favicon is a simple task, but once you start considering vendor-specific icons, it becomes more complicated.

Read more...

Python type hints: split types by Python version

The typing module continues to evolve, with new features in every Python version. This can make it tricky if you’re trying to type code that supports multiple Python versions. To help write such code, Mypy identifies version checks using sys.version_info and reads the appropriate branch.

Read more...

Set up EditorConfig for your Django project

The “tabs versus spaces” war is scheduled to rage on until the heat death of the universe. And whilst the Python ecosystem is firmly in the “spaces” camp, there remain numerous other text formatting options.

Read more...

How to Fix a Python “SyntaxError: invalid character” Caused by Curly Quotes

Here’s an innocent enough looking Python file:

Read more...

Python: make simple mocks with SimpleNamespace

When testing Python code you may need a mock object. That’s okay! But what’s the best way to build a simple mock?

Read more...

Book-Driven Development from “Boost Your Django DX”

On Monday I released my new book “Boost Your Django DX”. It covers many tools and practices that are useful for developing Django projects.

Read more...

Removing Python 3.6 Support from My Packages

Python 3.6 reached its end of life on the 23rd December. As its release manager put on the Python forum, it has gracefully “ridden off into the sunset”.

Read more...

“Boost Your Django DX” Released

My new book, Boost Your Django DX is out now. I’m so glad it has shipped and I can relax, a bit 😅

Read more...

My Third Appearance on Django Chat

I’ve again had the pleasure of joining Carlton and Will on the Django Chat podcast, in Episode #105. They moved fast with this one - we spoke yesterday, and the podcast is live today!

Read more...

How to Make an Immutable Dict in Python

Python’s built-in collection types come in mutable and immutable flavours, but one is conspicuously missing:

Read more...