DjangoRpc 0.3

Django RPC for jQuery

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.

The MIT License (MIT)


Dmitriy Kostochko




  • Topic :: Internet :: WWW/HTTP :: Dynamic Content
  • Topic :: Internet :: WWW/HTTP
  • Programming Language :: Python :: 2.7
  • Programming Language :: Python :: 2.6
  • Programming Language :: Python
  • Operating System :: OS Independent
  • License :: OSI Approved :: MIT License
  • Intended Audience :: Developers
  • Framework :: Django
  • Environment :: Web Environment
File Type Python Version Uploaded On Downloads
DjangoRpc-0.3.tar.gz Source Sept. 6, 2013 1,361
Version Release Date
0.3 Sept. 6, 2013
0.2 June 14, 2013
0.1.1 June 5, 2013
0.1.0 June 4, 2013
Date Package Version Action
Nov. 4, 2014, 1:45 p.m. DjangoRpc 0.2 Release Created
Nov. 4, 2014, 1:45 p.m. DjangoRpc 0.3 Release Created
Nov. 4, 2014, 1:45 p.m. DjangoRpc 0.1.1 Release Created
Nov. 4, 2014, 1:45 p.m. DjangoRpc 0.1.0 Release Created
Nov. 4, 2014, 1:45 p.m. DjangoRpc Package Created