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

Editing objects

From the course: Django: Forms

Start my 1-month free trial

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…

Contents