#NEWLINE# def get_valid_fields( self , queryset , view ) : #NEWLINE# #INDENT# "Return valid fields for ordering.\n\n        Overwrites DRF's get_valid_fields method so that valid_fields returns\n        serializer fields, not model fields.\n        " #NEWLINE# valid_fields = getattr ( view , 'ordering_fields' , self . ordering_fields ) #NEWLINE# if ( ( valid_fields is None ) or ( valid_fields == '__all__' ) ) : #NEWLINE# #INDENT# serializer_class = getattr ( view , 'serializer_class' ) #NEWLINE# if ( serializer_class is None ) : #NEWLINE# #INDENT# msg = "Cannot use %s on a view which does not have either a 'serializer_class' or 'ordering_fields' attribute." #NEWLINE# raise ImproperlyConfigured ( ( msg % self . __class__ . __name__ ) ) #NEWLINE# #UNINDENT# valid_fields = [ ( field_name , field . label , ( field . source or field_name ) ) for ( field_name , field ) in serializer_class ( ) . fields . items ( ) if ( ( not getattr ( field , 'write_only' , False ) ) and ( not ( field . source == '*' ) ) ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# serializer_class = getattr ( view , 'serializer_class' ) #NEWLINE# valid_fields = [ ( field_name , field . label , ( field . source or field_name ) ) for ( field_name , field ) in serializer_class ( ) . fields . items ( ) if ( ( not getattr ( field , 'write_only' , False ) ) and ( not ( field . source == '*' ) ) and ( field_name in valid_fields ) ) ] #NEWLINE# #UNINDENT# return valid_fields