Appendix B. Django Form Field Objects
This appendix is a quick reference for when you add fields to forms. The first section of this appendix discusses the different types of field objects. The second section discusses the Widget objects that translate to HTML elements. The third section discusses form field to model field mapping.
Field Objects
You can add several different types of fields to forms. The advantage of different types of fields is that the form can more closely match the data types that are put into it and validated.
The following sections describe the different types of Field
objects.
BooleanField
The BooleanField
is used to display an HTML checkbox input element. The following list describes the BooleanField
:
Default Widget:
CheckboxInput ...
Get Sams Teach Yourself Django in 24 Hours now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.