docs: def modelserializer_factory(model, serializer=serializers.ModelSerializer, fields=None, exclude=None, **kwargs):
      """
      Generate serializer basing on django's modelform_factory
      :param model: model we create serializer for
      :param serializer: base serializer class
      :param fields: list of fields to include in serializer
      :param exclude: list of fields to exclude from serializer
      :param kwargs: fields mapping
      :return:
      """
  
      # TODO: decide if we need cache and what to do with parameters tha can be different
      serializer_class = serializer_cache.get(model, None)
  
      if serializer_class:
          return serializer_class
  
      def _get_declared_fields(attrs):
          fields = [(field_name, attrs.pop(field_name))
                    for field_name, obj in list(attrs.items())
                    if isinstance(obj, serializers.Field)]
          fields.sort(key=lambda x: x[1]._creation_counter)
          return OrderedDict(fields)
  
      meta_attrs = {'model': model}
      if fields is not None:
          meta_attrs['fields'] = fields
      if exclude is not None:
          meta_attrs['exclude'] = exclude
      if fields is None and exclude is None:
          meta_attrs['fields'] = '__all__'
  
      parent = (object, )
      Meta = type(str('Meta'), parent, meta_attrs)
      class_name = model.__name__ + str('Serializer')
  
      serializer_class_attrs = {
          'Meta': Meta,
          '_get_declared_fields': _get_declared_fields(kwargs),
      }
      serializer_class = type(serializer)(class_name, (serializer,), serializer_class_attrs)
      serializer_cache[model] = serializer_class
      return serializer_class