Answer the question
In order to leave comments, you need to log in
Rendering with Ajax in Django?
Multiple queryset in each counter result. Two buttons. So how to display the result by clicking on the button without reloading the page? Where to dig in functions or where?
Answer the question
In order to leave comments, you need to log in
jQuery.get on the client side.
JSONResponse on the backend side:
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)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question