post-thumb

Learn about django Forms

In this tutorial we will learn about django forms and implemenation in real projects.

In django we can implement form concept using two ways

1.Forms API

2.Model API

 

1.Forms API.

you can make epython class to make form, which is simple ,secure and validation also too.

Django handles three distict parts of the work involved in forms like

i.preparing and restructuring data to make it ready for rendering

ii.creating HTML forms for the data

iii.receving and processing submitted forms and data from client.

Create a django forms using form class

from django import forms
class StudentForm(forms.Form):
    """syntax 
    label=forms.fieldType()
    """
    name=forms.CharField()
    roll=forms.IntegerField(label='roll number')

 then after creating forms , you can create form object in views.py file and render it into the template. remember that , form

 object won't provide form tag and button you need to write them manually.