CharField with huge max_length

Using TextField for very long string fields would simplify the code and make is easier to maintain.

CharField should be used for smaller strings and TextField should be used for larger strings.

CharField max_length adds value when the value is known format (phone numbers, ISBN) with a known maximum valid length.

For arbitrary long text the max_length adds scope for unwanted validation errors without adding value elsewhere. Remove it and rely on unconstrained TextField.

So in practice, do this

class SomeModel(models.Model):
    some_field = models.TextField()

Instead of this

class SomeModel(models.Model):
    some_field = models.CharField(max_length=1000)

Are you affected? Check with
pip install django-doctor

Configuring this check

Django Doctor will run this check by default. No configuration is needed but the check can be turned on/off using check code huge-max-length in your pyproject.toml file.

Read more about configuring Django Doctor.