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.
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.
Retrieve, update or delete a comment instance.
"""
"""
def get_object(self, pk):
def get_object(self, pk):
try:
try:
return Poll.objects.get(pk=pk)
return Comment.objects.get(pk=pk)
except Poll.DoesNotExist:
except Comment.DoesNotExist:
raise Http404
raise Http404
def get(self, request, pk, format=None):
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
...
@@ -56,28 +57,16 @@ So far, so good. It looks pretty similar to the previous case, but we've got be