On Mon, Oct 12, 2020 at 6:52 AM Ashutosh Mishra <ashutoshmishra...@gmail.com> wrote:
> I have create update api in django,but i am not getting its api link in > postman Not sure what is the "api link" you are referring to, is it the link you expect to get in the "api summary" or is it a link you expect to get in the response of the view? If the second, you should include it in the serializer or directly in the view response - you are only returning "success" and maybe "message" in your view > urls.py > from rest_framework.routers import DefaultRouter > from doctor import views > from .views import* > router=DefaultRouter() > router.register(r'Patient', views.PatViewSet, basename='PatViewSet') > router.register(r'Sch', views.TotalViewSet, basename='TotalViewSet') > router.register(r'Doctor', views.DocViewSet, basename='DocViewSet') > > urlpatterns = router.urls > > views.py > 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) > > -- > You received this message because you are subscribed to the Google Groups > "Django REST framework" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-rest-framework+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-rest-framework/62644d15-e1f4-4beb-ad84-0ecaadf51109n%40googlegroups.com > <https://groups.google.com/d/msgid/django-rest-framework/62644d15-e1f4-4beb-ad84-0ecaadf51109n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/CA%2BFDnhJK47ZZBYh8qrr0Yrim9%3DE0%3DhHGjF6ktHz4aOu1Wd%3D8BQ%40mail.gmail.com.