Пример #1
0
 def create(self,request):
     try:
         serializer=CompanySerliazer(data=request.data,context={"request":request})
         serializer.is_valid(raise_exception=True)
         serializer.save()
         dict_response={"error":False,"message":"Company Data Save Successfully"}
     except:
         dict_response={"error":True,"message":"Error During Saving Company Data"}
     return Response(dict_response)
Пример #2
0
    def update(self,request,pk=None):
        try:
            queryset=Company.objects.all()
            company=get_object_or_404(queryset,pk=pk)
            serializer=CompanySerliazer(company,data=request.data,context={"request":request})
            serializer.is_valid(raise_exception=True)
            serializer.save()
            dict_response={"error":False,"message":"Successfully Updated Company Data"}
        except:
            dict_response={"error":True,"message":"Error During Updating Company Data"}

        return Response(dict_response)