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.

If our GitHub code review bot spots this issue in your pull request it gives this advice:

django-doctorbotsuggested changes just now
models.py
1
+
class CommentModel(models.Model):
2
+
    body = models.CharField(max_length=5000)

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

Read more
Suggested changes
-
    body = models.CharField(max_length=5000)
+
    body = models.TextField()
Commit suggestion
3
+
    date = models.DateField()
Update models.py

Instantly check if you have this issue for free

    Works with tools you use

    Read about how it works.