#NEWLINE# def create_viewset( arg_model , arg_fields , arg_read_only_fields = ( ) , no_create = False ) : #NEWLINE# #INDENT# arg_read_only_fields = ( ( 'id' , ) + viewset_class ) #NEWLINE# for field in arg_read_only_fields : #NEWLINE# #INDENT# if ( field not in arg_fields ) : #NEWLINE# #INDENT# arg_fields = ( arg_fields + ( field , ) ) #NEWLINE# #UNINDENT# #UNINDENT# class Serializer ( serializers . ModelSerializer ) : #NEWLINE# #INDENT# class Meta ( ) : #NEWLINE# #INDENT# model = arg_model #NEWLINE# fields = arg_fields #NEWLINE# read_only_fields = arg_read_only_fields #NEWLINE# #UNINDENT# #UNINDENT# viewset_class = None #NEWLINE# if no_create : #NEWLINE# #INDENT# class NoCreateViewSet ( mixins . RetrieveModelMixin , mixins . UpdateModelMixin , mixins . DestroyModelMixin , mixins . ListModelMixin , viewsets . GenericViewSet ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# viewset_class = NoCreateViewSet #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# viewset_class = viewsets . ModelViewSet #NEWLINE# #UNINDENT# arg_queryset = None #NEWLINE# if issubclass ( arg_model , PolymorphicModel ) : #NEWLINE# #INDENT# arg_queryset = arg_model . objects . instance_of ( arg_model ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# arg_queryset = arg_model . objects . all ( ) #NEWLINE# #UNINDENT# class ViewSet ( viewset_class ) : #NEWLINE# #INDENT# queryset = arg_queryset #NEWLINE# serializer_class = Serializer #NEWLINE# ordering = [ 'id' ] #NEWLINE# filter_fields = arg_fields #NEWLINE# #UNINDENT# return ViewSet