Skip to main content

Django RPC for jQuery

Project description

Django RPC for jQuery. Allows execute some server-side class methods with Javascript in your browser.

Also you can submit forms with jQuery Form Plugin.

It also supports call batching. Django RPC batches together calls which are received within a configurable time frame and sends them in a single request.

You can easy move you current views to RPC methods and use Django RPC instead of mess of AJAX requests.

Inspired by Ext.Direct from ExtJs 3.

Package Documentation

Github repo


Install using pip:

pip install DjangoRpc

…or clone the project from github:
  1. Add djangorpc application to INSTALLED_APPS settings:


Now all required JS files are accessible via Django staticfiles application.

  1. Add jQuery to your page. You can use one fro application for quick start:

    <script src="{% static 'djangorpc/js/jquery-1.9.1.min.js' %}"></script>
  2. In your base templates add required JS scripts:

    <script src="{% static 'djangorpc/js/jquery.util.js' %}"></script>
    <script src="{% static 'djangorpc/js/jquery.rpc.js' %}"></script>
    <script src="{% static 'djangorpc/js/jquery.form.js' %}"></script>
  1. You can handle all errors in one place and show some message to user:

    //Show error message for RPC exceptions
    jQuery.Rpc.on('exception', function(event){
        alert('Error during RPC request: '+event.message);
  2. Do not forget about CSRF for Ajax requests.


Let’s take a look at a quick example how to use Django RPC application.

We’ll create a page with a button, which calls server-side method using Django RPC.

Create in your project folder with following code:

from djangorpc import RpcRouter, Msg

class MainApiClass(object):

    def hello(self, username, user):
        return Msg(u'Hello, %s!' % username)

rpc_router = RpcRouter({
    'MainApi': MainApiClass(),

Add this to

from django.conf.urls import patterns, include, url
from rpc import rpc_router

urlpatterns = patterns('someproject.someapp.views',
    url(r'^rpc/', include(rpc_router.urls))

Add following code to page template:

<script src="{% url 'jsapi' %}"></script>
    MainApi.hello('username', function(resp, sb){

Reload page and you will see an alert with the message “Hello, username!”.

The working project example you can find in our repo.


Development for this software happend on github, and the main fork is currently at

Contributions are welcome in any format, but using github’s pull request system is very highly preferred since it makes review and integration much easier.

Project details

Release history Release notifications

History Node


This version
History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
DjangoRpc-0.3.tar.gz (74.8 kB) Copy SHA256 hash SHA256 Source None Sep 6, 2013

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page