0

#settings///////// I use DateTimeField in Django and I can't get it to only show Y/M/D Hour/Min, it shows 2021-02-20T02: 06: 04.674Z. I am showing the data with json

DATE_FORMAT='%m/%d/%Y %H:%M:%S'

DATETIME_FORMAT='%m/%d/%Y %H:%M:%S'

USE_L10N = False

USE_TZ = True



--------------------

#model

{ creation_date = models.DateTimeField(auto_now_add=True)}
------------

#index.js Please help

function listadoIncidentes(){
    $.ajax({
        url: "/incidente/listar_incidentes/",
        type: 'get',
        dataType:"json",
        success: function(response){
            $('#tabla_incidentes tbody').html("");
            for (let i = 0; i < response.length; i++){
                let fila = '<tr>';
                fila += '<td>' + response[i]["fields"]['id'] + '</td>'
                fila += '<td>' + response[i]["fields"]['categoria'] + '</td>'
                fila += '<td>' + response[i]["fields"]['subCategoria'] + '</td>'
                fila += '<td>' + response[i]["fields"]['estado'] + '</td>'
                fila += '<td>' + response[i]["fields"]['titulo'] + '</td>'
                fila += '<td>' + response[i]["fields"]['fecha_creacion'] + 

In my view I have

class ListarIncidentes(View):
model = Incidente
form_class = IncidenteForm
context_object_name = 'incidentes'
template_name = 'incidente/listar_incidentes.html'

def get_queryset(self):
    return self.model.objects.filter(estado_de_eliminacion = True)

def get_context_data(self, **kwargs):
    context = {}
    context["incidentes"] = self.get_queryset()
    context["form"] = self.form_class
    return context

def get(self, request, *args, **kwargs):
    if request.is_ajax():
        data = serialize('json',self.get_queryset())
        return HttpResponse(data,'application/json')
    else:
        return redirect('incidente:inicio_incidentes')

0 Answers0