Send email with DataTable query data
I need help to know how to send an email with the list shown by dataTable, I have put a custom buttom that when clicked I would like to send an email with the whole list.
tblActividades = $ ('#tblActividades').DataTable ({
pageLength: 25,
responsive: true,
autoWidth: false,
destroy: true,
deferRender: true,
ajax: {
url: window.location.pathname,
type: 'POST',
data: {
'action': 'search_alumn',
},
dataSrc: ""
},
dom: 'Bfrtip',
buttons: [
{
extend: 'excelHtml5',
text: '<i class="fas fa-file-excel"></i> Descargar Excel',
titleAttr: 'Excel',
className: 'btn btn-info btn-sm btnPrintExcell'
},
{
extend: 'pdfHtml5',
text: '<i class="fas fa-file-pdf"></i> Descargar Pdf',
titleAttr: 'PDF',
className: 'btn btn-success btn-sm btnPrint',
download: 'open',
orientation: 'landscape',
pageSize: 'LEGAL',
customize: function (doc) {
doc.styles = {
header: {
fontSize: 18,
bold: true,
alignment: 'center'
},
subheader: {
fontSize: 13,
bold: true
},
quote: {
italics: true
},
small: {
fontSize: 8
},
tableHeader: {
bold: true,
fontSize: 11,
color: 'white',
fillColor: '#2873b6',
alignment: 'center'
}
};
doc.content[1].table.widths = ['20%', '20%', '15%', '15%', '15%', '15%'];
doc.content[1].margin = [0, 35, 0, 0];
doc.content[1].layout = {};
doc['footer'] = (function (page, pages) {
return {
columns: [
{
alignment: 'left',
text: ['Fecha de creación: ', {text: date_now}]
},
{
alignment: 'right',
text: ['página ', {text: page.toString ()}, ' de ', {text: pages.toString ()}]
}
],
margin: 20
}
});
}
},
{
text: '<i class="fas fa-reply"></i> Reiniciar',
className: 'btn btn-danger btn-sm btnReset',
action: function (e, dt, node, config) {
$ ('select[name="Actividades"]').val ('').trigger ('change.select2');
$ ('select[name="Meses"]').val ('').trigger ('change.select2');
$ ('select[name="search_horarios"]').val ('').trigger ('change.select2');
id_act = -1;
list_alumnos_inicio ();
}
},
{
text: '<i class="far fa-envelope"></i> Enviar',
className: 'btn btn-warning btn-sm btnReset',
action: function (e, dt, node, config) {
/*Abrir modal con listado de monitores para enviar email*/
listado_monitores ()
$ ('#myModalMonitores').modal ('show');
}
}
],
columns: [
{"data": "full_name"},
{"data": "telf"},
{"data": "email"},
{"data": "fecha_nacimiento"},
],
columnDefs: [
{
targets: [-1],
class: 'text-center',
orderable: false,
render: function (data, type, row) {
var fecha = row.fecha_nacimiento;
const opciones = {year: 'numeric', month: 'long', day: 'numeric'};
const fomateada = new Date (fecha).toLocaleDateString ('es-ES', opciones);
return fomateada;
}
},
],
There I have the query of the DataTable and in that query, with that data, are the ones I want to send by email, I am working with Django, all the send function and the url is done, what I can't understand is how to send that list to the Django view. If someone helps me I would be very grateful.