| web | https://adamj.eu/ |
|---|---|
| Author |
Nov. 25, 2025 » Adam Johnson » [Archived Version]
HTTP has a general authentication framework that defines a pattern into which various authentication schemes can fit. Clients may provide an authorization request header that contains a credential. If authorization is missing or invalid, the server may respond with a 401 (Unauthorized) status code, including a www-authenticate header advertising what …
Read MoreNov. 20, 2025 » Adam Johnson » [Archived Version]
Here are some Django-related deals for this year’s Black Friday (28th November) and Cyber Monday (1st December), including my own. I’ll keep this post up to date with any new deals I learn about. If you are also a creator, email me with details of your offer and …
Read MoreOct. 9, 2025 » Adam Johnson » [Archived Version]
HTTP supports response compression, which can significantly reduce the size of responses, thereby decreasing bandwidth usage and load times for users. It’s a cheap and valuable technique for improving website performance. Lighthouse, Google’s web performance auditing tool, recommends enabling compression where it is not enabled, presenting estimated bandwidth …
Read MoreSept. 21, 2025 » Adam Johnson » [Archived Version]
Django’s runserver automatically reloads when you change Python files. Without this autoreloading feature, you’d need to manually restart the server every time you made a code change. However, the default autoreloading implementation is inefficient, as it constantly polls the filesystem for changes. The alternative to polling is to …
Read MoreJuly 31, 2025 » Adam Johnson » [Archived Version]
Here’s a little tip based on some work that I did recently. The project has a URL pattern where the first part of the URL matches the current role the user is viewing the site as. Let’s say the roles are “chef”, “gourmand”, and “foodie”—example URLs might …
Read MoreJuly 29, 2025 » Adam Johnson » [Archived Version]
Within Django’s popular admin site, you can override ModelAdmin.get_queryset() to customize the queryset used by the admin views. It’s often used for performance optimizations, such as adding a select_related() call to batch-fetch related objects: from django.contrib import admin from example.models import Book @admin.register(Book …
Read MoreJuly 21, 2025 » Adam Johnson » [Archived Version]
I’ve found it useful, on occasion, to iterate through all registered URL patterns in a Django project. Sometimes this has been for checking URL layouts or auditing which views are registered. In this post, we’ll look at a pattern for doing that, along with an example use case …
Read MoreJune 26, 2025 » Adam Johnson » [Archived Version]
From Django 5.2 (April 2025), the runserver management command outputs a warning: $ ./manage.py runserver ... Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. WARNING: This is a development server. Do not use it in a production setting. Use a production WSGI or …
Read MoreJune 23, 2025 » Adam Johnson » [Archived Version]
I recently released a new package called inline-snapshot-django. It’s a tool for snapshot testing SQL queries in Django projects, described shortly. Snapshot testing and inline-snapshot inline-snapshot-django builds on top of the excellent inline-snapshot, a nifty snapshot testing library. Snapshot testing is a type of testing that compares a result …
Read MoreMay 2, 2025 » Adam Johnson » [Archived Version]
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 …
Read More