from django.http import JSONResponse
from django.views.generic import View
from .models import MyModel
class MyView(View):
def get(self, request, *args, **kwargs):
result = {'count': MyModel.objects.count()}
return JSONResponse(result)