def get_setter_func(field_name, value):
    """
    Returns the setter function patched to the target model.
    :param field_name: the name of the field storing the choice
    :param value: the value to set
    :return: function
    """

    def func(self, commit=False):
        setattr(self, field_name, value)
        if commit:
            self.save()

    return func