Field Validations and Built-In Fields - Django Models
Last Updated :
10 Oct, 2025
Field validations in Django ensure that the data entered into the database is correct and follows specific rules. Django automatically checks the data based on the type of field used, so no extra validation code is required. Each type of field in Django has its own built-in checks:
- IntegerField only accepts whole numbers.
- CharField is for text and limits how long the text can be.
- DateField checks that the value is a valid date.
If invalid data is entered, Django raises an error and prevents saving.
Example: Consider a project named 'geeksforgeeks' having an app named 'geeks'.
In geeks/models.py:
Python
from django.db import models
class GeeksModel(models.Model):
geeks_field = models.IntegerField()
def __str__(self):
return str(self.geeks_field)
After running makemigrations and migrate, Django creates the corresponding database table with an integer column.
If you try to create an instance using a string value like 'GfG is Best' for geeks_field, Django’s validation system will raise an error, as only integers are allowed.

You can verify it through Django admin interface, you’ll notice that non-numeric input is automatically rejected - demonstrating how each field enforces its own built-in validation.
Django provides fields for almost every type of data, such as IntegerField for numbers and CharField for text. In addition, there are built-in validations that can be applied to these fields to enforce extra rules. Some of the most used validations are listed below:
Field Options | Description |
---|
Null | If True, Django will store empty values as NULL in the database. Default is False. |
Blank | If True, the field is allowed to be blank. Default is False. |
db_column | The name of the database column to use for this field. If this isn’t given, Django will use the field’s name. |
Default | The default value for the field. This can be a value or a callable object. If callable it will be called every time a new object is created. |
help_text | Extra “help” text to be displayed with the form widget. It’s useful for documentation even if your field isn’t used on a form. |
primary_key | If True, this field is the primary key for the model. |
editable | If False, the field will not be displayed in the admin or any other ModelForm. They are also skipped during model validation. Default is True. |
error_messages | The error_messages argument lets you override the default messages that the field will raise. Pass in a dictionary with keys matching the error messages you want to override. |
help_text | Extra “help” text to be displayed with the form widget. It’s useful for documentation even if your field isn’t used on a form. |
verbose_name | A human-readable name for the field. If the verbose name isn’t given, Django will automatically create it using the field’s attribute name, converting underscores to spaces. |
validators | A list of validators to run for this field. See the validators documentation for more information. |
Unique | If True, this field must be unique throughout the table. |
Read Next: Custom Field Validations in Django Models
Explore
Python Fundamentals
Python Data Structures
Advanced Python
Data Science with Python
Web Development with Python
Python Practice
My Profile