With your formset, you need some special code in your views. Nick goes through this in this video.
- [Instructor] Now it's time to create a function … for the pizzas view. … So, let's go ahead and make that function. … That's just going to be def pizzas. … We'll go ahead and pass self into there. … And with this pizzas, we hopefully are getting good … information about the number of pizzas that people want, … but maybe that's going to get spoofed or tricked somehow, … so we're going to provide a default … where we're going to say number of pizzas … is going to be equal to two. … Now hopefully what will happen is we'll say … our filled_multiple_pizza_form, … very descriptive here, is going to be equal to, … our MultiplePizzaForm, and pass inside of there … our request., all caps, GET. … Okay, so hopefully that gives us a number … that the user provided between two and six, … but we've got to check and make sure that that's valid, … so we're going to say if filled_multiple_pizza_form … .is_valid, so if this is all good, … then we're going to say, alright, … well then the number of pizzas, …
- Creating form fields
- Using submitted data
- Adding models
- Using the ModelForms class
- Working with widgets
- Accepting files and multiple forms on a page
- Customizing formsets
- Using local validation
- Delivering errors responsibly
- Customizing forms
- Styling with CSS
Skill Level Intermediate
Building RESTful Web APIs with Djangowith Rudolf Olah1h 9m Intermediate
1. Getting Started with Forms
2. Working with Advanced Form Features
3. Customizing and Styling Form Appearance
Next steps1m 19s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.