Opened 17 years ago
Closed 17 years ago
#4623 closed (fixed)
Needs newforms description of how to "do form processing"
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | newforms | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I couldn't figure out how to do my own form processing for days... then I learned it was as simple as:
form = MyForm(request.POST)
if form.is_valid():
# Capture data, store to DB.
mymodel.title = form.clean_datatitle
mymodel.description = form.clean_datadescription
mymodel.save()
is_valid() cleans the incoming POST data, and stores the result in form.clean_data[]
Note:
See TracTickets
for help on using tickets.
The section Using forms in views and templates covers a full example of using a form to validate data. If this doesn't cover what you're looking for, please open a new ticket with specific suggestions.