def log_query(func):
 def wrapper(obj, query_string, *args, **kwargs):
  start = time()
  try:
   return func(obj, query_string, *args, **kwargs)
  finally:
   stop = time()
   if settings.DEBUG:
    from haystack import connections
    connections[obj.connection_alias].queries.append({u'query_string': query_string, u'additional_args': args, u'additional_kwargs': kwargs, u'time': (u'%.3f' % (stop - start)), u'start': start, u'stop': stop})
 return wrapper

def log_query ( func ) : def wrapper ( obj , query_string , * args , ** kwargs ) : start = time ( ) try : return func ( obj , query_string , * args , ** kwargs ) finally : stop = time ( ) if settings . DEBUG : from haystack import connections connections [ obj . connection_alias ] . queries . append ( { u'query_string' : query_string , u'additional_args' : args , u'additional_kwargs' : kwargs , u'time' : ( u'%.3f' % ( stop - start ) ) , u'start' : start , u'stop' : stop } ) return wrapper
a decorator for pseudo-logging search queries .