A Django text field allows NULL, so an empty value can be stored in two ways

tx0/python:django-nullable-text-fieldstrictnotesmell

What it finds

A CharField or TextField with null=True can hold both NULL and the empty string for "no value", and queries have to test for both. Django's convention is to store the empty string and leave null off. Fields with unique=True, where several empty strings would clash, are left alone.

From the rule's source, django_nullable_text_field.rs.

Example from the rule's tests
from django.db import models class Book(models.Model):    title = models.CharField(max_length=100, null=True)tx0 reports: this CharField can store both NULL and the empty string    body = models.TextField(null=True, blank=True)tx0 reports: this TextField can store both    isbn = models.CharField(max_length=13, null=True, unique=True)    year = models.IntegerField(null=True)
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:django-nullable-text-field" = "note"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

# tx0: ignore[tx0/python:django-nullable-text-field] reason="..."

tx0 explain tx0/python:django-nullable-text-field shows the same in the terminal. Found a false positive? Report it.