class TotalViewSet(viewsets.ViewSet):
def update(self,request,pk=None):
try:
data=request.data
doctor=Doctor.objects.get(pk=pk)
print(doctor)
timings=data.get('schedule')
DAYS=Schedule.DAYS
for day in DAYS:
sch=Schedule()
sch.doctor=doctor
sch.days=day[0]
sch.start_time=timings[day[1]]['start_time']
sch.end_time=timings[day[1]]['end_time']
sch.save()
return Response({"success": True}, status=status.HTTP_200_OK)
except Exception as error:
#traceback.print_exc()
return Response({"message": str(error), "success": False}, status=status.HTTP_200_OK)