return HttpResponse('Hello, World!')
def post(self, request, *args, **kwargs): return HttpResponse('Hello, World!')
def put(self, request, *args, **kwargs): return HttpResponse('Hello, World!')
def delete(self, request, *args, **kwargs): return HttpResponse('Hello, World!')
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2cbd1753-d7d3-40d2-9d47-e935d0e3d75f%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACNsr2-Y7bPvDmCYRdLiZf5vVDbs6tX4EABF5HGzDUt3wvOjLA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BEpJfxOrX0thTdb%3DoikwmTyGYCGVo4zdbGyA6UxvvyV3E7TLg%40mail.gmail.com.
class SnippetDetail(APIView):
"""
Retrieve, update or delete a snippet instance.
"""
def get_object(self, pk):
try:
return Snippet.objects.get(pk=pk)
except Snippet.DoesNotExist:
raise Http404
def get(self, request, pk, format=None):
snippet = self.get_object(pk)
serializer = SnippetSerializer(snippet)
return Response(serializer.data)
def put(self, request, pk, format=None):
snippet = self.get_object(pk)
serializer = SnippetSerializer(snippet, data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def delete(self, request, pk, format=None):
snippet = self.get_object(pk)
snippet.delete()
return Response(status=status.HTTP_204_NO_CONTENT)
urlpatterns = [ path('snippets/<int:pk>/', views.SnippetDetail.as_view()), ]
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BEpJfxOrX0thTdb%3DoikwmTyGYCGVo4zdbGyA6UxvvyV3E7TLg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABL_bk2poNSOa0ajfM3NP1XOSg_5T8R3NZHYN%2BtGfGd_cWrRxQ%40mail.gmail.com.
![]() |
Shakil Ahmmed
about.me/shakilahmmed
|
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7aada502-1f1c-4eef-b4ba-70dcc4bee3ec%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACNsr2-pd_MeLdkCqpDP3ARLE_0sWWoVywv1pVw64sv2-ZH17g%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BEpJfzP24WT1DCnaVRn3WjsV-AHwMVK9%2BiLokWg_2x5pBrtwg%40mail.gmail.com.