Fast and easy AJAX libraries for django applications.
3.x
2.x
Install django-ajax in your python environment
1- Download and install package:
Through Github:
or simply with:
2- Add 'django_ajax'
into the INSTALLED_APPS
list.
3- Read usage section and enjoy this feature!
When the view does not return anything, you will receive this response (JSON format):
Sending content
The whole result is converted into a JSON format as part of the content element:
Combining with others decorators
The location or path of the redirection response will be given in the content item, also the status and statusText will reflect what is going on:
Template response
The JSON response:
Catch exceptions
The JSON response:
If you are using AJAX at all times in your project, we suggest you activate the AJAXMiddleware described below.
Add django_ajax.middleware.AJAXMiddleware
to the MIDDLEWARE_CLASSES
list in settings.py
and all your responses will be converted to JSON whereas the request was made via AJAX, otherwise it will return a normal HttpResponse.
Caution
If this middleware is activated you cannot use the @ajax
decorator. That will cause double JSON conversion.
AJAXMixin
is an object that call to AJAX decorator.
The JSON response:
Enjoy And Share!