You can return the HttpResponseNotFound here, and drop the if statement.