django-planet

Feed: Adam Johnson

Blog Adam Johnson
RSS 2.0 Feed Adam Johnson
web https://adamj.eu/
Last Update11.14.2024
Posts60

Boost Your DX bundle deal update

Dec. 29, 2023 » Adam Johnson » [Archived Version]

My two “Boost Your DX” books are available in a bundle deal, saving $10 compared to buying them separately. Great for improving your Django and Git skills at the same time. Buy the bundle on Gumroad This offer does not apply to team licenses. I initially created a bundle deal …

Read More

Django: Detect the global privacy control signal

Dec. 27, 2023 » Adam Johnson » [Archived Version]

Global Privacy Control (GPC) is a specification for web browsers to signal website operators not to share or sell the user’s data. This signal is intended to exercise legal data privacy rights such as those provided by the California Consumer Privacy Act (CCPA) or the EU’s General Data …

Read More

Django: Sanitize incoming HTML fragments with nh3

Dec. 13, 2023 » Adam Johnson » [Archived Version]

A fairly common situation in a Django project is where you need to store and serve arbitrary HTML fragments. These often come from forms with rich text editors (using HTML’s contenteditable). It’s insecure to trust user-generated HTML fragments since they can contain naughty content like: <script src=https …

Read More

Django Quiz 2023

Dec. 11, 2023 » Adam Johnson » [Archived Version]

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. Here it is so you can try it at home - answers are at the bottom. Dates refer to …

Read More

Django: Defer a model field by default

Dec. 11, 2023 » Adam Johnson » [Archived Version]

Some models have one or a few large fields that dominate their per-instance size. For example, take a minimal blog post model: from django.db import models class Post(models.Model): blog = models.ForeignKey("Blog", on_delete=models.CASCADE) title = models.TextField() body = models.TextField() body is typically many times larger …

Read More

Django: Fix version 5.0’s URLField.assume_scheme warnings

Dec. 7, 2023 » Adam Johnson » [Archived Version]

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 …

Read More

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

Nov. 9, 2023 » Adam Johnson » [Archived Version]

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. This behaviour was observed on PostgreSQL 14, so things may have improved since. Although …

Read More

Boost Your DX bundle deal

Oct. 15, 2023 » Adam Johnson » [Archived Version]

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. Today I’m happy to announce the bundle deal for …

Read More

My fourth appearance on Django Chat

Sept. 20, 2023 » Adam Johnson » [Archived Version]

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: Favourite features coming in Django 5.0 My new book, Boost Your Git …

Read More

Django: Move a template tag library into builtins

Sept. 14, 2023 » Adam Johnson » [Archived Version]

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 …

Read More