We import the forms library, inherit from the Form class, and declare the form's fields to construct a Form. The following is a very basic form class for our library book renewal form; copy and paste it into your new file: Import the forms class RenewBookForm(forms. Form) from Django: renewal date = forms.
Django templates can be used in HTML (full or partial), text, XML, JSON, and almost any other text-based format.
Open catalog/views.py and notice that it already imports the render() shortcut method from django to build an HTML file using a template and data:. # importing render Here you can express yourself. The first line imports the model classes that we'll use in all of our views to access data.
Django's form is also easier to use when designing a form that sends data to a database table. Django forms make it simple to move data from a form to a database table. It's better to use plain HTML forms when designing any type of sophisticated form that requires complex style.