As I understand from this database design question, you should use nullable fields sparingly and make a weighed decision each time on whether it would be better to rethink data design instead.
But let's say in some particular case the resolution is to allow a text field to contain an empty value. Say, there's user
table and there's short_bio
column that is represented by the TextField in Django and is not mandatory. It doesn't make sense to create a separate user_bio
table, right?
Now the question is, should the empty value be an empty string or null marker? What are pros and cons for each option? Are there any specifics in how Django works with database that can make difference?
It should be noted that django-lint currently reports on CharField and TextField instances with null=True
.
Conversely, ‘storing an empty string for a field left blank is seen as a Bad Idea’ by some developers.