def require_post_params(required_params):
 def _decorator(func):
  @wraps(func)
  def _wrapped(*args, **_kwargs):
   request = args[0]
   missing_params = (set(required_params) - set(request.POST.keys()))
   if (len(missing_params) > 0):
    msg = u'Missing POST parameters: {missing}'.format(missing=', '.join(missing_params))
    return HttpResponseBadRequest(msg)
   else:
    return func(request)
  return _wrapped
 return _decorator

def require_post_params ( required_params ) : def _decorator ( func ) : @ wraps ( func ) def _wrapped ( * args , ** _kwargs ) : request = args [ 0 ] missing_params = ( set ( required_params ) - set ( request . POST . keys ( ) ) ) if ( len ( missing_params ) > 0 ) : msg = u'Missing POST parameters: {missing}' . format ( missing = ', ' . join ( missing_params ) ) return HttpResponseBadRequest ( msg ) else : return func ( request ) return _wrapped return _decorator
checks for required parameters or renders a 400 error .