AJAX request required decorator
    use it in your views:

    @ajax_required
    def my_view(request):
        ....

def ajax_required(func):
    # taken from djangosnippets.org
    """
    AJAX request required decorator
    use it in your views:

    @ajax_required
    def my_view(request):
        ....

    """
    def wrap(request, *args, **kwargs):
        if not request.is_ajax():
            return HttpResponseBadRequest
        return func(request, *args, **kwargs)
    wrap.__doc__ = func.__doc__
    wrap.__name__ = func.__name__
    return wrap