shtalinberg / django-el-pagination

Django endless pagination tools. Ajax, multiple and lazy pagination, Twitter-style and Digg-style pagination.
MIT License
307 stars 71 forks source link

How to differentiate between multiple paginations in the view code? #86

Closed int-ua closed 7 years ago

int-ua commented 7 years ago

I have a view in which paginated items take only part of the page. Beside them there is a lot of content that takes some time to be generated in the view code. AFAIU that generation occurs even on AJAX page load unless I add something like this on the start:

    if request.is_ajax():
        data = {
            'items': publications,
        }

        return render_to_response(
            page_template,
            data,
            context_instance=RequestContext(request))

What is the best way to get a querystring key in this part in case of multiple paginations with AJAX?

int-ua commented 7 years ago

I did it like this:

if request.is_ajax():
    key = request.GET.get(
        'querystring_key',
        request.POST.get('querystring_key', 'page'))