def follow_question(request): "关注问题" if request.method=="POST": qid=request.POST.get("qid",None) typecode=request.POST.get("type",None) if qid and typecode: if typecode=="0": follow=QustionFollow(question_id=qid,user_id=request.user.id) follow.follow_question(request.user) else: follow=QustionFollow.objects.filter(question_id=qid,user_id=request.user.id)[0] follow.cancel_follow(request.user) return HttpResponse() else: return Http404
def follow_question(request): "关注问题" if request.method=="POST": qid=request.POST.get("qid",None) typecode=request.POST.get("type",None) question=get_question_from_redis(int(qid)) if qid and typecode: if typecode=="0": follow=QustionFollow(question=question,user=request.user) follow.follow_question(request.user) follow_question_to_redis(qid,request.user.id) else: follow=QustionFollow.objects.filter(question=question,user=request.user)[0] follow.cancel_follow(request.user) cancel_follow_question_to_redis(qid,request.user.id) return HttpResponse() else: return Http404
def follow_question(request): "关注问题" if request.method == "POST": qid = request.POST.get("qid", None) typecode = request.POST.get("type", None) question = get_question_from_redis(int(qid)) if qid and typecode: if typecode == "0": follow = QustionFollow(question=question, user=request.user) follow.follow_question(request.user) follow_question_to_redis(qid, request.user.id) else: follow = QustionFollow.objects.filter(question=question, user=request.user)[0] follow.cancel_follow(request.user) cancel_follow_question_to_redis(qid, request.user.id) return HttpResponse() else: return Http404