Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Internet > Django Plugins

    django-ajax-toolkit 0.2

    Download button

    No screenshots available
    Downloads: 126  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Excellent (5.0/5)
    1 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Eleni Lixourioti | More programs
    BSD License / FREE
    June 15th, 2012, 10:49 GMT
    ROOT / Internet / Django Plugins

     Read user reviews (0)  Refer to a friend  Subscribe

    django-ajax-toolkit description

    Ajax goodies for Django projects

    django-ajax-toolkit is a Django app that provides Ajax goodies for Django projects.

    Returning JSON in views

    JsonResponse

    If you want to extend your views to work with ajax you may choose to return json data in your response. To make this easier you can use JsonResponse found in ajaxtoolkit.http:

    from ajaxtoolkit.http import JsonResponse

    class MyView(TemplateView):

     def get(self, request, *args, **kwargs):
     if request.is_ajax:
     context = self.get_context_data()
     return JsonResponse(context)
     # ...


    This will set the correct mimetype (application/json) and serialise your context data into a json object.

    Ajax Middleware

    If you're using Django's messages framework, you can also add ajaxtoolkit.middleware.AjaxMiddleware in your middleware.

    This will inject all messages generated in your request into your JsonResponse object:

    from django.contrib import messages
    from ajaxtoolkit.http import JsonResponse

    class MyView(TemplateView):

     def get(self, request, *args, **kwargs):
     if request.is_ajax:
     context = self.get_context_data()

     messages.info(request, "This is very useful")
     messages.warning(request, "Be careful!")

     return JsonResponse(context)
     # ...


    This would be rendered as the following:

    {
     //...
     'django_messages': [
     {"extra_tags": "info",
     "message": "This is very useful",
     "level": 20},
     {"extra_tags": "warning",
     "message": "Be careful!",
     "level": 30}
     ]
    }



    Product's homepage

    Requirements:

    · Python
    · Django
    · simplejson

      


    TAGS:

    Django projects | Ajax toolkit | Django | projects | Ajax

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM