Tuesday, September 5, 2017

Re: how to write APIview to access a specific item by using APIViews only



On Tuesday, September 5, 2017 at 8:06:09 PM UTC+5:30, Vijay Khemlani wrote:
To retrieve a particular object in your API you should implement it in a method called "retrieve", not "get", if I remember correctly

On Tue, Sep 5, 2017 at 10:28 AM, Rakhee Menon <menonr...@gmail.com> wrote:
CODE:

class FormList(APIView):
def get(self, request, id):
import ipdb;ipdb.set_trace()
item_obj = ItemMaster.objects.get(id=id)
serializer = ItemMasterSerializer(forms,many=False)
return Response(serializer.data, content_type="application/json")
def get(self,request):
forms = ItemMaster.objects.all()
serializer=ItemMasterSerializer(forms,many=True)
return Response(serializer.data, content_type="application/json")



I get this error.django-got-an-unexpected-keyword-argument-id. 
when i try to access a specific item..Please can anyone suggest how to solve this bug using APIViews and not by using viewset  as there is lot of customization in my API.

--
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 post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8f1a1edf-ed7f-490f-8c29-73aa31531a3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d658fd4d-2056-4c4f-bb28-0b10964c39a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment