Update 3-class-based-views.md

This commit is contained in:
smavity 2020-09-30 10:42:34 +01:00 committed by GitHub
parent be87eb43b3
commit 622d5a6ef8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -142,6 +142,15 @@ Using the mixin classes we've rewritten the views to use slightly less code than
queryset = Snippet.objects.all()
serializer_class = SnippetSerializer
class SnippetUpdate(generics.UpdateAPIView):
queryset = Snippet.objects.all()
serializer_class = SnippetSerializer
class SnippetDestroy(generics.DestroyAPIView):
queryset = Snippet.objects.all()
serializer_class = SnippetSerializer
Wow, that's pretty concise. We've gotten a huge amount for free, and our code looks like good, clean, idiomatic Django.
Next we'll move onto [part 4 of the tutorial][tut-4], where we'll take a look at how we can deal with authentication and permissions for our API.