1 回答
TA贡献1827条经验 获得超8个赞
def get_employees(position, start, end):
return employee.objects.filter(alert_time__lt=end,alert_time__gt=start).filter(position__in=position)
@login_required
def show(request):
if not validate(request):
return render_to_response('none.html',
context_instance=RequestContext(request, 'msg':'params error')
)
position = request.REQUEST.get('position')
time_range = request.REQUEST.get('time')
start, end = time_range[0], time_range[1]
num_per_page, page_num = get_num(request)
all_employees = get_employees(position, start, end)
# 根据当前页与每页展示的记录数,取到正确的记录
employees = employees_events[(page_num-1)*num_per_page:page_num*num_per_page]
return render_to_response('show_employees.html',
context_instance=RequestContext(
request,
'employees': employees,
'num_per_page': num_per_page,
'page_num':page_num,
'page_options' : [50, 100, 200]
)
)
- 1 回答
- 0 关注
- 752 浏览
添加回答
举报