Code Fellows 401
Day 28 Notes
Home
Reading
Django Forms
Bookmark and Review
Django Templates
Django Views
Things I want to know more about
- A form is a way to collect data from the user and send it to the server.
- In Django, forms are created by inheriting from the forms.Form class or the forms.ModelForm class.
- The forms.Form class allows you to define the fields of the form and their validation rules.
- The forms.ModelForm class is used when the form is based on a model, it will automatically generate the form fields based on the model’s fields.
- Forms can be rendered in templates using the form.as_p, form.as_table, and form.as_ul methods.
- Form data is sent to the server using the HTTP POST method.
- In the view, the form data is accessed using the request.POST or request.GET attribute, depending on the method used in the form.
- Form data is validated using the is_valid() method, and errors can be accessed using the errors attribute.