def get_serializer_class(configuration_model):
    """ Returns a ConfigurationModel serializer class for the supplied configuration_model. """
    class AutoConfigModelSerializer(ModelSerializer):
        """Serializer class for configuration models."""

        class Meta(object):
            """Meta information for AutoConfigModelSerializer."""
            model = configuration_model
            fields = '__all__'

        def create(self, validated_data):
            if "changed_by_username" in self.context:
                model = get_user_model()
                validated_data['changed_by'] = model.objects.get(username=self.context["changed_by_username"])
            return super(AutoConfigModelSerializer, self).create(validated_data)

    return AutoConfigModelSerializer
Returns a ConfigurationModel serializer class for the supplied configuration_model.