<input id="search_{{ table.table_id }}" type="text" class="form-control table-search" placeholder="Search">
<script>
    filter = {
        init: function (table) {
            $('#search_{{ table.table_id }}').keyup(function () {
                table.table.api().search(this.value).draw();
            });
            try {
                $('#search_{{ table.table_id }}').val(table.table.api().state.loaded().search.search);
            } catch (e) {
                console.log(e)
            }
        },

        clear: function () {
            table = django_datatables.DataTables['{{ table.table_id }}'].table
            table.api().search('');
            $('#search_{{ table.table_id }}').val('')
        }
    }
    django_datatables.add_plugin('{{ table.table_id }}', filter)
</script>