how to redirect in django rest framework

Solutions on MaxInterview for how to redirect in django rest framework by the best coders in the world

showing results for - "how to redirect in django rest framework"
Conor
06 Apr 2017
1class entry_ViewSet(viewsets.ModelViewSet):
2    queryset = Entry.objects.all()
3    serializer_class= EntrySerializer
4    permission_classes = (permissions.IsAuthenticatedOrReadOnly,IsOwnerOrReadOnly,)
5
6    def create(self, request, *args, **kwargs):
7        response = super(entry_ViewSet, self).create(request, *args, **kwargs)
8        # here may be placed additional operations for
9        # extracting id of the object and using reverse()
10        return HttpResponseRedirect(redirect_to='https://google.com')
11
12    def perform_create(self, serializer):
13        serializer.partial = True
14        serializer.save(created_by=self.request.user)
15