Avoiding empty strings in non-nullable Django string-based model fields

Trying to save a null value to a non-nullable field in Django will raise an IntegrityError, right? Well, not always. It turns out that Django saves string-based model fields as the empty string into the database instead. Usually, this is ok. For those times that it isn’t, you’ll need to add a constraint. Here, I explain how the situation arises and how to avoid it, if you want to.