import json

from django.http import JsonResponse
from django.shortcuts import render
from django.views.generic.list import ListView
from django.core import serializers

from .models import VistaTotal

class VistaTotalLV(ListView):
    model = VistaTotal
    template_name = "vistatotal.html"
    queryset = VistaTotal.objects.using('flor').all()


def vistatotal(request):
    data = serializers.serialize("json", VistaTotal.objects.using('flor').all())
        # Turn the JSON data into a dict and send as JSON response
    return JsonResponse(json.loads(data), safe=False)
    # data = VistaTotal.objects.using('flor').all()
    # return JsonResponse(data, safe=False)