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.
Editing objects
- [Instructor] Well now that we can save pizzas. How great would it be if we could allow the user to edit a pizza? And that's exactly what we're going to do here. So let's go ahead and make a new path for someone to edit a pizza order. We'll copy our existing pizzas. And we're going to change this to be order/ and then inside of angle brackets we're going to say int:pk and this is to say they can add a primary key for what pizza it is that they're looking for. So we'll change this to be edit_order and we'll do the same thing for the name. So, we have a new URL path here. The next step for us is to move over to our views. We're going to have to be working with a pizza model. So let's go ahead and import that. We'll say from.modelsimportPizza, great. And then the next step for us is to say okay, if someone's going to create a pizza, let's go ahead and save that into something. So we're going to say created pizza is equal to whenever the saved form is filled. And then we're going to…
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)
-
-