@login_required
@ensure_csrf_cookie
def view_tracking_log(request, args=''):
 if (not request.user.is_staff):
  return redirect('/')
 nlen = 100
 username = ''
 if args:
  for arg in args.split('/'):
   if arg.isdigit():
    nlen = int(arg)
   if arg.startswith('username='):
    username = arg[9:]
 record_instances = TrackingLog.objects.all().order_by('-time')
 if username:
  record_instances = record_instances.filter(username=username)
 record_instances = record_instances[0:nlen]
 fmt = '%a %d-%b-%y %H:%M:%S'
 for rinst in record_instances:
  rinst.dtstr = rinst.time.replace(tzinfo=pytz.utc).astimezone(pytz.timezone('US/Eastern')).strftime(fmt)
 return render_to_response('tracking_log.html', {'records': record_instances})

@ login_required @ ensure_csrf_cookie def view_tracking_log ( request , args = '' ) : if ( not request . user . is_staff ) : return redirect ( '/' ) nlen = 100 username = '' if args : for arg in args . split ( '/' ) : if arg . isdigit ( ) : nlen = int ( arg ) if arg . startswith ( 'username=' ) : username = arg [ 9 : ] record_instances = TrackingLog . objects . all ( ) . order_by ( '-time' ) if username : record_instances = record_instances . filter ( username = username ) record_instances = record_instances [ 0 : nlen ] fmt = '%a %d-%b-%y %H:%M:%S' for rinst in record_instances : rinst . dtstr = rinst . time . replace ( tzinfo = pytz . utc ) . astimezone ( pytz . timezone ( 'US/Eastern' ) ) . strftime ( fmt ) return render_to_response ( 'tracking_log.html' , { 'records' : record_instances } )
view to output contents of trackinglog model .