Tuesday, October 12, 2010

Reponse code for a require_XHR decorator?

Hi,

I want to add an require_XHR decorator to my project. The implementation is pretty straightforward.

def require_XHR(f):
    @wraps(f)
    def wrapper(request, *args, **kwargs):
        if not request.is_ajax():
            return HttpResponseBadRequest()
        return f(request, *args, **kwargs)
    return wrapper

But the question is, is Bad Request (HTTP Status Code 400) the best choice? Which response code do you use in such a situation?

Best regards,
Oliver

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment