Django is a Python web framework and it is easy to add script.aculo.us scripts to a Django-powered application.
Download the Javascript files and place them in your static Javascript directory. See How to serve static files for more information about media and static files with Django.
Include prototype.js and scriptaculous.js in any template file where you would like to use scriptaculous effects.
It’s really easy to use Prototype’s Ajax functions with Django! Just add the URL to your urls.py file which might look something like:
(r'^ajax/hello_world/$', 'myapplication.mysite.ajax.hello_world')
For this example the Python code used to handle the AJAX request would go in ajax.py in the hello_world function. The AJAX function needs to return a Http Response object.
Example Prototype Ajax call:
new Ajax.Request('/ajax/hello_world', {method:'post', asynchronous:true});
Example Ajax function (in ajax.py):
from django.http import HttpResponse, HttpResponseServerError
def hello_world(request):
if request.method == 'GET':
print 'error - expecting POST request'
return HttpResponseServerError;
print 'Hello World!'
return HttpResponse('OK')
Pretty boring example, but you can make things more interesting by using Ajax to manipulate your models and send back information. Python data can also be formatted as JSON using one of the serializers available for Django.
This very un-official documentation was contributed by Leah Culver. Hope it helps!