#NEWLINE# def update( self , request , user__username = None ) : #NEWLINE# #INDENT# ( preferences , created ) = UserPreferences . objects . get_or_create ( user = request . user ) #NEWLINE# serializer = self . serializer_class ( instance = preferences , data = request . data ) #NEWLINE# if serializer . is_valid ( ) : #NEWLINE# #INDENT# serializer . update ( ) #NEWLINE# return Response ( { #NEWLINE# #INDENT# 'status' : 'updated preferences' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return Response ( serializer . errors , status = status . HTTP_400_BAD_REQUEST )