I am getting the url while printing it

On Wed 14 Oct, 2020, 14:07 Ashutosh Mishra, <ashutoshmishra...@gmail.com>
wrote:

> buddy i have tried the way i have coded,i have got results too,but today i
> am not getting
>
> On Wednesday, October 14, 2020 at 9:45:28 AM UTC+5:30 rsalg...@gmail.com
> wrote:
>
>> print the urlpatterns and check what are all the urls router is
>> registering for TotalViewSet. If you dont see an url for update, my guess
>> is viewsets.ViewSet doesn't automatically catch the update function as its
>> not the method of ViewSet. In this case you are trying to override update
>> method. and if you want your router to register the url for update, you
>> should use ModelViewSet instead of ViewSet.
>>
>> On Wednesday, October 14, 2020 at 9:24:57 AM UTC+5:30
>> ashutosh...@gmail.com wrote:
>>
>>> can anyone see my code through teamviewer ?
>>>
>>>
>>> On Monday, October 12, 2020 at 11:34:54 PM UTC+5:30 matemat...@gmail.com
>>> wrote:
>>>
>>>> On Mon, Oct 12, 2020 at 6:52 AM Ashutosh Mishra <ashutosh...@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-fram...@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 a topic in the
> Google Groups "Django REST framework" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-rest-framework/ENFa7Oa8utU/unsubscribe
> .
> To unsubscribe from this group and all its topics, 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/f9482bb0-f7ca-4167-b44b-f5698f3c9047n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-rest-framework/f9482bb0-f7ca-4167-b44b-f5698f3c9047n%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/CAGDmY67-Xg0ngQAReom4dZFO7SBFe_tw93SnEARugyfrxu9Scw%40mail.gmail.com.

Reply via email to