Presumably, some view function needs to call this `handle_ajax` function, and return the response as a `HttpResponse` instance. How does the caller know if this function returned an error message? (If it did, the `HttpResponse` should have some sort of error status code, rather than 200.) It might be better to have this function raise an exception, which the caller can catch.