Django CharField


Example

The CharField is used for storing defined lengths of text. In the example below up to 128 characters of text can be stored in the field. Entering a string longer than this will result in a validation error being raised.

from django.db import models

class MyModel(models.Model):
    name = models.CharField(max_length=128, blank=True)