Hello,
I have in my models.py file a field of type CHOICES
VIA = [
('1', 'email'),
('2', 'Insitu'),
('3', 'Telefono'),
]
class Rec(models.Model):
id = models.AutoField(primary_key=True)
estado = models.IntegerField(verbose_name='estado', null=True)
fecha_reclamacion = models.DateField(null=True,)
fecha_resolucion = models.DateField(verbose_name='Fecha_resolucion', null=True)
num_reclamacion = models.CharField(max_length=100, null=True)
num_cliente = models.CharField(max_length=100, null=True)
empresa = models.CharField(max_length=100, null=True)
tipo = models.CharField(max_length=100,null=False,blank=False,choices=TIPO_EMPRESA)
atiende = models.CharField(max_length=100, null=True,)
atiende_code = models.IntegerField(verbose_name='Atiende_code', null=True)
departamento = models.CharField(max_length=100, null=True)
del_dep_code = models.CharField(max_length=100, null=True)
via = models.CharField(max_length=100,null=False,blank=False,choices=VIA,default=1)
To save a record the text appears correctly but when saving it already saves with the assigned number.
What I would like is when displaying the records, instead of displaying the assigned number, display the text.
I show the records through a DataTable, I attach part of the code since in this js code I call the different fields of the record
function listadoReclamaciones(){
$.ajax({
url: "/reclamaciones/listado_reclamaciones/",
type:"get",
dataType: "json",
success: function(response){
if($.fn.DataTable.isDataTable('#tabla_reclamaciones')){
$('#tabla_reclamaciones').DataTable().destroy();
}
$('#tabla_reclamaciones tbody').html("");
for(let i = 0;i < response.length;i++){
let fila = '<tr>';
fila += '<td>' + (i +1) + '</td>';
fila += '<td>' + response[i]["fields"]['num_reclamacion'] + '</td>';
fila += '<td>' + response[i]["fields"]['via'] + '</td>';
fila += '<td>' + response[i]["fields"]['fecha_reclamacion'] + '</td>';
fila += '<td>' + response[i]["fields"]['aprueba'] + '</td>';