Commits

sirex committed 1843a53

Check if ajax request is really ajax request.

Comments (0)

Files changed (1)

annoying/decorators.py

 from django import forms
 from django.template import RequestContext
 from django.db.models import signals as signalmodule
-from django.http import HttpResponse
+from django.http import HttpResponse, HttpResponseBadRequest
 from django.utils import simplejson
 
 __all__ = ['render_to', 'signals', 'ajax_request', 'autostrip']
     """
     @wraps(func)
     def wrapper(request, *args, **kwargs):
+        if not request.is_ajax():
+            return HttpResponseBadRequest
         response = func(request, *args, **kwargs)
         if isinstance(response, dict):
             return JsonResponse(response)