liveBook · Manning

Web form

As explained in Django in Action

A web form is an HTML-based interface through which a user enters and submits data to a web application.

A web form is an HTML interface for collecting and submitting user data. In Django, a Form object can describe fields and render their corresponding HTML, while a view decides how submitted data is processed. section 7.1

A Django form connects several practical pieces:

  • Fields correspond to HTML elements. CharField commonly becomes an <input type="text">, while EmailField becomes an email input. section 7.1
  • Widgets control the resulting HTML tag and some attributes, including text areas, selects, radio buttons, dates, times, and file inputs. section 7.1
  • Form rendering is optional: templates can render the fields, but custom HTML is still needed when layout requirements exceed the form’s controls. section 7.1
  • Forms require buttons rather than links for actions such as logout, and POST forms include CSRF protection. section 6.4.1

A small comment form

Define a CommentForm with name and comment fields, using a Textarea widget for the longer response. Instantiating it and calling as_p() produces labels, inputs, required attributes, and IDs ready for template output.

How Django in Action covers it

How deep it goes
Explains fields, widgets, rendering, and CSRF usage, but leaves submitted-data processing to the programmer’s view.
Examples
Demonstrates login fields, a comment form, generated HTML, and a POST logout form styled like a link.
What it assumes
Builds from HTML tags and Django views while treating submitted-data processing as application code rather than automatic form behavior.
What you can do after
Build forms with Django fields and widgets, render their HTML, and connect submissions to application-specific views.
How it connects
Connects HTML, Django Form objects, widgets, templates, views, sessions, and CSRF protection.

Also explained in

Compare how 12 books explain web form →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Django in Action. The section links point to the parts of the book it draws on.