Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7770971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:32:07+00:00 2026-06-01T16:32:07+00:00

I am writing a simple Django application and wish to add ajax paging using

  • 0

I am writing a simple Django application and wish to add ajax paging using Dajax / Dajaxice. I have started by trying to implement the simple paging example from the Dajax website (http://dajaxproject.com/pagination/) – but haven’t managed to get it working. Whenever I press the “next” button I get the following js error:

Uncaught TypeError: Cannot call method 'pagination' of undefined

My Django project is called “DoSomething” – and it contains a single app called “core”.

I have followed all of the instructions to install Dajaxice here: https://github.com/jorgebastida/django-dajaxice/wiki/installation

I have an python file in the “core” directory called “ajax.py” which contains the following code:

from views import get_pagination_page
from dajax.core.Dajax import Dajax
from django.template.loader import render_to_string
from dajaxice.decorators import dajaxice_register
from django.utils import simplejson

@dajaxice_register
def pagination(request, p):
    try:
        page = int(p)
    except:
        page = 1
    items = get_pagination_page(page)
    render = render_to_string('posts_paginator.html', { 'items': items })

    dajax = Dajax()
    dajax.assign('#pagination','innerHTML',render)
    return dajax.json()

My views.py file contains the following method:

def index(request):
    posts = Post.objects.order_by('id').reverse()
    items = get_pagination_page(1)
    return render_to_response('index.html', locals(), context_instance=RequestContext(request))

def get_pagination_page(page=1):
    from django.core.paginator import Paginator, InvalidPage, EmptyPage
    from django.template.loader import render_to_string
    items = Post.objects.order_by('id').reverse()
    paginator = Paginator(items, 10)
    try:
        page = int(page)
    except ValueError:
        page = 1
    try:
        items = paginator.page(page)
    except (EmptyPage, InvalidPage):
        items = paginator.page(paginator.num_pages)
    return items

My index template contains the following:

<div id="pagination">
    {% include "posts_paginator.html" %}
</div>

My posts_paginator.html template contains the following link, to trigger the pagination method:

{% for i in items.object_list %}
    {{ i }}<br>
{% endfor %}
{% if items.has_next %}
    <a href="#" onclick="Dajaxice.core.pagination(Dajax.process,{'p':{{ items.next_page_number }}})">next</a>
{% endif %}

My question is, within the onClick value, how should I be referencing the pagination method (from my ajax.py file). I can’t find anything to explain this – and I’ve tried every combination of project name/app name that I can think of!

THANKS! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:32:08+00:00Added an answer on June 1, 2026 at 4:32 pm

    At least in my case I have to append the Project name as well as the app_label.

    Dajaxice.MyProject.core.my_dajax_method(Dajax.process, {'form' : data});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a simple search server, using Django with AJAX. The server
I'm writing a simple blog-like application for Django and am trying to get the
I'm writing simple GUI using wxPyhon and faced some problems. My application does simple
I'm writing a simple private messenger using Django and am implementing message threading. Each
I am writing a fairly simple Django application where users can enter string queries.
I'm writing a simple real-estate listing app in Django. Each property needs to have
I'm writing fairly simple application which connects to server through SSH (using paramiko ),
I'm writing a simple chat with ajax and I have a problem with JSON.
I'm writing a simple web app in PHP that needs to have write access
I'm writing a simple game and I'm going to have the mouse control the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.