'Pickling support function.
Ensures that the object can\'t be pickled before it has been
rendered, and that the pickled state only includes rendered
data, not the data used to construct the response.'

def __getstate__(self):

    obj_dict = super(TemplateResponse, self).__getstate__()
    del obj_dict['_request']
    del obj_dict['_current_app']
    return obj_dict
