Django Form | Data Types and Fields
Last Updated :
26 May, 2025
When collecting user input in Django, forms play a crucial role in validating and processing the data before saving it to the database. Django provides a rich set of built-in form field types that correspond to different kinds of input, making it easy to build complex forms quickly.
Each form field type comes with its own validation logic and widget (HTML input type) to help gather and verify user data efficiently.
To master form handling and other Django functionalities, you can check Django Web Development Course.
Here is a summary of commonly used Django form fields, their purposes, and their default widgets:
BooleanField Represents a checkbox that stores True or False.
Default widget: CheckboxInput
Syntax:
field_name = forms.BooleanField(**options)
CharField Used for short to medium text inputs.
Default widget: TextInput
Syntax:
field_name = forms.CharField(**options)
ChoiceField lets users select one option from a predefined list.
Default widget: Select
Syntax:
field_name = forms.ChoiceField(**options)
DateField in Django Forms is a date field, for taking input of dates from the user.
Default widget: DateInput
Syntax:
field_name = forms.DateField(**options)
DateTimeField in Django Forms is a date field, for taking input of date and time from the user.
Default widget: DateTimeInput
Syntax:
field_name = forms.DateTimeField(**options)
DecimalField in Django Forms is a decimal field, for input of decimal numbers.
Default widget: NumberInput
Syntax:
field_name = forms.DecimalField(**options)
DurationField in Django Forms is used for input of particular durations for example from 12 am to 1 pm.
Default widget: TextInput
Syntax:
field_name = forms.DurationField(**options)
EmailField in Django Forms is a string field, for input of Emails. It is used for taking text inputs from the user.
Default widget: EmailInput
Syntax:
field_name = forms.EmailField(**options)
FileField in Django Forms is an input field for the upload of files.
Default widget: ClearableFileInput
Syntax:
field_name = forms.FileField(**options)
FilePathField selects a file path from the server.
Default widget: Select
Syntax:
field_name = forms.FilePathField(**options)
FloatField in Django Forms is an integer field, for taking input of floating point numbers from the user.
Default widget: NumberInput
Syntax:
field_name = forms.FloatField(**options)
GenericIPAddressField in Django Forms is a text field, for input of IP Addresses. It is a field containing either an IPv4 or an IPv6 address.
Default widget: TextInput
Syntax:
field_name = forms.GenericIPAddressField(**options)
ImageField in Django Forms is an input field for the upload of image files.
Default widget: ClearableFileInput
Syntax:
field_name = forms.ImageField(**options)
IntegerField in Django Forms is an integer field, for the input of Integer numbers.
Default widget: NumberInput
Syntax:
field_name = forms.IntegerField(**options)
MultipleChoiceField in Django Forms is a Choice field, for input of multiple pairs of values from a field.
Default widget: SelectMultiple
Syntax:
field_name = forms.MultipleChoiceField(**options)
NullBooleanField in Django Forms is a select field that stores either True or False. It is used for taking boolean inputs from the user.
Default widget: NullBooleanSelect
Syntax:
field_name = forms.NullBooleanField(**options)
RegexField in Django Forms is a string field, for small- to large-sized strings that one can match with a particular regular expression. It is used for taking selected text inputs from the user.
Default widget: TextInput
Syntax:
field_name = forms.RegexField(**options)
SlugField in Django Forms is a slug field, for input of slugs for particular URLs or similar. This field is intended for use in representing a model SlugField in forms.
Default widget: TextInput
Syntax:
field_name = forms.SlugField(**options)
TimeField in Django Forms is a time input field, for input of time for a particular instance or similar.
Default widget: TimeInput
Syntax:
field_name = forms.TimeField(**options)
TypedChoiceField in Django Forms is a field just like ChoiceField, for selecting a particular choice out of a list of available choices. It is used to implement State, Countries etc.
Default widget: Select
Syntax:
field_name = forms.TypedChoiceField(**options)
TypedMultipleChoiceField in Django Forms is a Choice field, for input of multiple pairs of values from a field and it includes a coerce function also to convert data into specific data types.
Default widget: SelectMultiple
Syntax:
field_name = forms.TypedMultipleChoiceField(**options)
URLField in Django Forms is a URL field, for the input of URLs from a user. This field is intended for use in representing a model URLField in forms.
Default widget: URLInput
Syntax
field_name = forms.URLField(**options)
UUIDField in Django Forms is a UUID field, for the input of UUIDs from a user.
Default widget: TextInput
Syntax:
field_name = forms.UUIDField(**options)
Read Next: Initial form data – Django Forms
Similar Reads
Django Tutorial | Learn Django Framework
Django, built with Python, is designed to help developers build secure, scalable, and feature-rich web applications quickly and efficiently. Whether you're a beginner looking to create your first dynamic website or an experienced developer aiming to enhance your skills, this tutorial will guide you
11 min read
Django view
Views In Django | Python
Django Views are one of the vital participants of the MVT Structure of Django. As per Django Documentation, A view function is a Python function that takes a Web request and returns a Web response. This response can be the HTML contents of a Web page, a redirect, a 404 error, an XML document, an ima
6 min read
Django Function Based Views
Django is a Python-based web framework which allows you to quickly create web application without all of the installation or dependency problems that you normally will find with other frameworks. Django is based on MVT (Model View Template) architecture and revolves around CRUD (Create, Retrieve, Up
7 min read
Django Class Based Views
Class-Based Views (CBVs) allow developers to handle HTTP requests in a structured and reusable way. With CBVs, different HTTP methods (like GET, POST) are handled as separate methods in a class, which helps with code organization and reusability.Advantages of CBVsSeparation of Logic: CBVs separate d
6 min read
Class Based vs Function Based Views - Which One is Better to Use in Django?
Django, a powerful Python web framework, has become one of the most popular choices for web development due to its simplicity, scalability and versatility. One of the key features of Django is its ability to handle views and these views can be implemented using either Class-Based Views (CBVs) or Fun
6 min read
Django Templates
Templates are the third and most important part of Django's MVT Structure. A Django template is basically an HTML file that can also include CSS and JavaScript. The Django framework uses these templates to dynamically generate web pages that users interact with. Since Django primarily handles the ba
7 min read
Django Static File
Static Files such as Images, CSS, or JS files are often loaded via a different app in production websites to avoid loading multiple stuff from the same server. This article revolves around, how you can set up the static app in Django and server Static Files from the same.Create and Activate the Virt
3 min read
Django Forms
Django Forms
When one creates a Form class, the most important part is defining the fields of the form. Each field has custom validation logic, along with a few other hooks. This article revolves around various fields one can use in a form along with various features and techniques concerned with Django Forms. D
6 min read
How to Create a form using Django Forms
This article explains how to create a basic form using various form fields and attributes. Creating a form in Django is very similar to creating a model, you define the fields you want and specify their types. For example, a registration form might need fields like First Name (CharField), Roll Numbe
2 min read
Django Form | Data Types and Fields
When collecting user input in Django, forms play a crucial role in validating and processing the data before saving it to the database. Django provides a rich set of built-in form field types that correspond to different kinds of input, making it easy to build complex forms quickly.Each form field t
4 min read
Django Form | Build in Fields Argument
We utilize Django Forms to collect user data to put in a database. For various purposes, Django provides a range of model field forms with various field patterns. The most important characteristic of Django forms is their ability to handle the foundations of form construction in only a few lines of
3 min read
Python | Form validation using django
Prerequisites: Django Installation | Introduction to DjangoDjango works on an MVT pattern. So there is a need to create data models (or tables). For every table, a model class is created. Suppose there is a form that takes Username, gender, and text as input from the user, the task is to validate th
5 min read
Render Django Form Fields Manually
Django form fields have several built-in methods to ease the work of the developer but sometimes one needs to implement things manually for customizing User Interface(UI). We have already covered on How to create and use a form in Django?. A form comes with 3 in-built methods that can be used to ren
5 min read
Django Admin Interface - Python
Prerequisites: Django Introduction and Installation Creating a ProjectThe Django Admin Interface is one of the most powerful features of the Django framework. It provides a ready-to-use interface for managing project data through models, allowing developers and site administrators to perform Create,
3 min read
More topics on Django
Handling Ajax request in Django
AJAX (Asynchronous JavaScript and XML) is a web development technique that allows a web page to communicate with the server without reloading the entire page. In Django, AJAX is commonly used to enhance user experience by sending and receiving data in the background using JavaScript (or libraries li
3 min read
User Groups with Custom Permissions in Django - Python
Our task is to design the backend efficiently following the DRY (Don't Repeat Yourself) principle, by grouping users and assigning permissions accordingly. Users inherit the permissions of their groups.Let's consider a trip booking service, how they work with different plans and packages. There is a
4 min read
Django Admin Interface - Python
Prerequisites: Django Introduction and Installation Creating a ProjectThe Django Admin Interface is one of the most powerful features of the Django framework. It provides a ready-to-use interface for managing project data through models, allowing developers and site administrators to perform Create,
3 min read
Extending and customizing django-allauth in Python
Django-allauth is a powerful Django package that simplifies user authentication, registration, account management, and integration with social platforms like Google, Facebook, etc. It builds on Djangoâs built-in authentication system, providing a full suite of ready-to-use views and forms.Prerequisi
4 min read
Django - Dealing with Unapplied Migration Warnings
Django is a powerful web framework that provides a clean, reusable architecture to build robust applications quickly. It embraces the DRY (Don't Repeat Yourself) principle, allowing developers to write minimal, efficient code.Create and setup a Django project:Prerequisite: Django - Creating projectA
2 min read
Sessions framework using django - Python
Django sessions let us store data for each user across different pages, even if theyâre not logged in. The data is saved on the server and a small cookie (sessionid) is used to keep track of the user.A session stores information about a site visitor for the duration of their visit (and optionally be
3 min read
Django Sign Up and login with confirmation Email | Python
Django provides a built-in authentication system that handles users, login, logout, and registration. In this article, we will implement a user registration and login system with email confirmation using Django and django-crispy-forms for elegant form rendering.Install crispy forms using the termina
7 min read