score:3

Accepted answer

i'd recommend you do use django-rest-framework because it's probably easier with pagination.

however, if you want to avoid that you could pass your own structure (obviously, you may need to pass other information such as next page/previous page etc).

the challenge here is ensuring everything is json serializable - that means for queryset you have to use .values() and wrap the result with list(). for paginator you need to wrap with list().

from django.http.response import jsonresponse

def index(request):
    influencers = influencer.objects.all().values()

    paginator = paginator(influencers,16)
    page = request.get.get('page')
    paged_listings = paginator.get_page(page)
    user_list = userlist.objects.all().filter(user_id = request.user.id).values()

    queryset = list(chain(paged_listings,user_list),paginator.count)
    content = {'total_page_count': paginator.num_pages, 'data': queryset}
    return jsonresponse(content)

Related Query

More Query from same tag