Code

Opened 7 years ago

Closed 7 years ago

#4623 closed (fixed)

Needs newforms description of how to "do form processing"

Reported by: cellmap@… Owned by: nobody
Component: Documentation Version: master
Severity: Keywords: newforms
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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[]

Attachments (0)

Change History (1)

comment:1 Changed 7 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.