reading-notes

code fellows reading notes

View on GitHub

Reading-Notes

Code Fellows Python 401

Read: 28 - Django CRUD and Forms

Django Forms

HTML Form

<form action="/team_name_url/" method="post">
    <label for="team_name">Enter name: </label>
    <input id="team_name" type="text" name="name_field" value="Default name for team.">
    <input type="submit" value="OK">
</form>

Form Handling Process

ex of form handling process

Form Class

Declaring a Form

from django import forms

class RenewBookForm(forms.Form):
    renewal_date = forms.DateField(help_text="Enter a date between now and 4 weeks (default 3).")

Form fields

The arguments that are common to most fields are listed below (these have sensible default values):

Validation

how to validate your data

Bookmark and Review