make_boolean_checkmark

Columns from demo: Interaction (no args)

Shortcut for coercing the column's data into a boolean True or False, but rendering a (✔) or (✘)

Any value can be used with this helper, as long as it can be assessed in an if value: statement. The helper can optionally be called with true_value and false_value arguments, which default to the entity strings shown above.

datatable_options = {
    'columns': [
        # Standard use, no need to actually call the helper
        ("Comments", 'n_comments', helpers.make_boolean_checkmark),
        # Specify custom string
        ("Blog", 'blog__name', helpers.make_boolean_checkmark(false_value="")),
    ],
}

You can use this helper in your own custom callbacks if there is some kind of value calculation that needs to be done before the helper should execute:

def get_column_Interaction_data(self, instance, *args, **kwargs):
    # Simplest use; grab the 'default_value' argument that DatatableView found for us
    return helpers.make_boolean_checkmark(kwargs['default_value'])
    
    # Specify custom true and/or false strings
    value = instance.get_some_value()
    return helpers.make_boolean_checkmark(value, true_value="Yes", false_value="No")