#100DaysOfWeb in Python Transcripts
Chapter: Days 69-72: Django REST Framework
Lecture: Implement the other CRUD methods

Login or purchase this course to watch this video and the rest of the course contents.
0:00 All right. Now we're going to add a view to look at quotes individually. Because as we've seen this is not working yet. So let's go over to my app.
0:20 And let's go into view.py. It's actually pretty awesome because in our web app we actually had to write quote detail, quote new, quote edit
0:32 and quote delete views all separately. But with Django REST framework we can just write three lines of code. We can just make a class based view
0:46 which we're going to call QuoteDetail and we're going to inherit from generics.RetrieveUpdateDestroyAPIView.
1:04 And the code is actually the same. We need a queryset and a serializer class which are the same as in the QuoteList class based view.
1:12 And the only second thing we need to do is to make a new route. So I can save this. And as we've seen in the browser we're going to reference
1:25 the primary key integer in the URL. And we point out to the new class based view.
1:53 All right. Let's check the this out. And look at that! Quote number two we can edit and delete. Same for four up till thirty.
2:10 And add a source. We can delete the quote. It's now gone if you deleted the cache at 204 that's correct.
2:28 And I can add a quote 201 for creation. Perfect. And I probably made 31.
2:45 Exactly. 18. Awesome. One final thing. I cannot really log out from this page. There's an easy way to support that: Adding another route.
3:00 So let's got to URLs, again. And let's add REST Frameworks URLs.
3:28 Hit refresh. And now I can log out. And here we see a program as well that when I'm logged out I can edit this data.
3:38 So next video's all about permissions.


Talk Python's Mastodon Michael Kennedy's Mastodon