django-planet
May 2, 2025

Django: model field choices that can change without a database migration

published by Adam Johnson
in blog Adam Johnson
original entry Django: model field choices that can change without a database migration

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 …