Uhm, give this a try:
import functools
def with_description(fn):
@functools.wraps(fn) # This is not strictly necessary, just pulls info (docstrings, etc) from fn and pushes into the wrapper
def wrapper(*args, **kwargs):
# Precheck
installation_name = request.args.get('installation_name', '')
if installation_name == '':
data = {"description": "Installation Name is required"}
return HttpResponse(json.dumps(data), status=400, mimetype='application/json')
# If precheck passes, call the actual function
fn(*args, **kwargs)
return wrapper
With this you win that every function decorated actually gets called only when the precheck passes.
EDIT
If as commented, you want to recycle the installation name, you just have to pass it to the function call. One possibility would be the following:
fn(installation_name, *args, **kwargs)
And of course, the decorated function has to expect that argument.