Model Fieldname restrictions in Django Framework Last Updated : 16 Feb, 2021 Comments Improve Suggest changes Like Article Like Report A Django model is the built-in feature that Django uses to create tables, their fields, and various constraints. In short, Django Models is the SQL of Database one uses with Django. SQL (Structured Query Language) is complex and involves a lot of different queries for creating, deleting, updating or any other stuff related to database. Django models simplify the tasks and organize tables into models. This article revolves around restrictions on models field names. Django places some restrictions on Model Field Names. First create the django project to see this restrictions django-admin startapp myprojcd myproj Then create new app. python manage.py startapp main Add main app in settings.py inside the INSTALLED_APPS Restrictions on Field Name - 1. Field name cannot be a python reserved word Example 1 Python3 from django.db import models # Create your models here. class Student(models.Model): pass = models.CharField(max_length=100) Error: Example 2 Python3 from django.db import models # Create your models here. class Student(models.Model): global = models.CharField(max_length=100) 2. A field name cannot contain more than one underscore in a row Python3 from django.db import models # Create your models here. class Student(models.Model): stu__name = models.CharField(max_length=100) Error: 3. A field name cannot end with an underscore Python3 from django.db import models # Create your models here. class Student(models.Model): stuname_ = models.CharField(max_length=100) Error: Comment More infoAdvertise with us Next Article Model Fieldname restrictions in Django Framework V vivekpisal12345 Follow Improve Article Tags : Python Web Technologies Python Django Practice Tags : python Similar Reads How to Change Field Name in Django REST Framework Serializer When working with Django REST Framework (DRF), we may encounter situations where we need to change the name of a field in a serializer. This can be useful when we want to expose a model field with a different name in our API or when we need to conform to a specific API schema. In this article, we wi 3 min read How To Filter A Nested Serializer In Django Rest Framework? When building APIs with Django Rest Framework (DRF), nested serializers are commonly used to represent relationships between models. A nested serializer allows us to include data from related models within a serializer. However, there are instances where we might want to filter the data returned by 6 min read Built-in Field Validations - Django Models Field validations in Django help make sure the data you enter into your database is correct and follows certain rules. Django automatically checks the data based on the type of field you use, so you donât have to write extra code to validate it yourself.Django provides built-in validations for every 3 min read Python | Relational fields in Django models Prerequisite: Django models  Django models represent real-world entities, and it is rarely the case that real-world entities are entirely independent of each other. Hence Django supports relational databases and allows us to establish relations between different models. There are three types of rel 4 min read Custom Field Validations in Django Models Field validation ensures that the data entered into a model field meets specific rules before itâs saved to the database. While Django provides built-in validations for common checks, custom field validation lets you enforce your own rules, such as verifying formats, length limits, or complex condit 3 min read Like