From the course: Django: Forms
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Model forms
- [Instructor] So, now that we have a new model, we're going to create a new form that's based off that model and it's going to saved us even more time than we already save from creating this Django Form. You're going to see, this is going to be really incredible. So let's first go ahead and comment out our pizza form class. So, I'm going to select all that. If I hit command and then forward slash and Adam, it comments it out for me automatically. Cool little trick there. And then we want to make sure that, up at the top here, we can say, from dot and we want models to import and let's go grab our pizza class. Alright, so with this in place, now we're going to be creating a form that's called a special kind of form. It's a form model or a model form, rather. So, let's go ahead and say class pizza form. Notice this is the exact same name that we have here, so this won't disrupt any of our view code or anything like that. We're going to say pizza form is coming from lowercase forms dot…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Adding models5m 59s
-
(Locked)
Model forms4m 1s
-
Working with widgets5m 37s
-
(Locked)
Advanced widgets4m 23s
-
(Locked)
Forms and files4m 4s
-
(Locked)
Formsets: Multiple forms on a page5m 18s
-
(Locked)
Formset views6m 34s
-
(Locked)
Controlling the number of formsets5m 40s
-
(Locked)
Editing objects4m 40s
-
(Locked)
Input confirmation4m 7s
-
(Locked)
-
-