Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to redirect in django rest framework

class entry_ViewSet(viewsets.ModelViewSet):
    queryset = Entry.objects.all()
    serializer_class= EntrySerializer
    permission_classes = (permissions.IsAuthenticatedOrReadOnly,IsOwnerOrReadOnly,)

    def create(self, request, *args, **kwargs):
        response = super(entry_ViewSet, self).create(request, *args, **kwargs)
        # here may be placed additional operations for
        # extracting id of the object and using reverse()
        return HttpResponseRedirect(redirect_to='https://google.com')

    def perform_create(self, serializer):
        serializer.partial = True
        serializer.save(created_by=self.request.user)
Comment

PREVIOUS NEXT
Code Example
Python :: how to use virtual environment python 
Python :: python list to bytes 
Python :: pandas sort by date descending 
Python :: append to pandas dataframe 
Python :: how to display address in python 
Python :: matplotlib secondary y axis 
Python :: how to make a numpy array 
Python :: python with file 
Python :: python continue 
Python :: python raise and exit 
Python :: pandas to latex 
Python :: python path from string 
Python :: round down a number python 
Python :: # Take user input in python 
Python :: sang nguyen to python 
Python :: figsize param in pandas plot 
Python :: how to make calculator in python 
Python :: python iterate backwards through list 
Python :: pandas apply function on two columns 
Python :: python bool to string 
Python :: how to add an item to a list in python 
Python :: multipart/form data multipart encoder python 
Python :: pyautogui press enter 
Python :: start virtual environment python 
Python :: how to change username of a bot using discord.py 
Python :: pandas read from txt separtion 
Python :: concatenate dataframes pandas without duplicates 
Python :: difference between generator and iterator in python 
Python :: how to resize windows in python 
Python :: write list to file python 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =