Django Form Validation Without Model

To use form validation in Django without using a model, pass forms.Form as the first argument of the form class rather than forms.ModelForm.

 

Here is an example of a simple Django form validation class independent from a model to demonstrate this:

 

myapp/forms.py
from django import forms

from .models import Calculator

class AgeForm(forms.Form):

    name = forms.CharField()

 

 

Thats it! now you can do any type of validation on a request without the data having to conform to any model.