def get_post(request, img_id): """ 获取与img_id相邻的三个img """ img_id = get_int(img_id) request.img_id = img_id if img_id == 0: index(request) else: p = Img.objects.filter(pk=img_id).order_by('id') is_none_raise_404(p) return render_to_response('fascinate/post.html', {'post': p}, context_instance=RequestContext(request))
def index(request): p = Img.objects.order_by('-create_at')[:2] is_none_raise_404(p) return render_to_response('fascinate/index.html', {'post': p})