So far, so good. It looks pretty similar to the previous case, but we've got better seperation between the different HTTP methods. We'll also need to update the instance view.
class CommentInstance(views.APIView):
class CommentInstance(APIView):
"""
Retrieve, update or delete a comment instance.
"""
def get_object(self, pk):
try:
return Poll.objects.get(pk=pk)
except Poll.DoesNotExist:
return Comment.objects.get(pk=pk)
except Comment.DoesNotExist:
raise Http404
def get(self, request, pk, format=None):
...
...
@@ -56,28 +57,16 @@ So far, so good. It looks pretty similar to the previous case, but we've got be