def deal_with_comment(request, **kwargs): question_id = kwargs['question_id'] answer_id = kwargs['answer_id'] answer = Answer.objects.get(id=answer_id) comment = request.POST.get('comment') c = Comment(user=request.user, belong_to_answer=answer) c.comment = comment c.save() return details(request, question_id=question_id)
def comment(request): token = request.session.get('token') userid = cache.get(token) user = User.objects.get(pk=userid) goodsid = request.POST.get('goodsid') comment = request.POST.get('comment') identifier = request.POST.get('identifier') goods = Goods.objects.get(pk=goodsid) comm = Comment() comm.user = user comm.goods = goods comm.comment = comment comm.save() print(identifier) order = Order.objects.filter(identifier=identifier).first() order.status = 4 order.save() return redirect('app:myorder')
print post_user db_post = Post(description=post["description"], creation_date=datetime.datetime.now(), user=post_user, picture=None) picture_path = "post_pictures/%s" % path_leaf(post["picture"]) post_picture = open("instagram/media/" + picture_path, "r") db_post.picture.save(picture_path, File(post_picture)) db_post.save() likes = post["likes"] for like in likes: db_like = Like() db_like.user = InstagramUser.objects.filter(username=like)[0] db_like.post = db_post db_like.save() comments = post["comments"] for comment in comments: comment_user = InstagramUser.objects.filter(username=comment["user"])[0] db_comment = Comment() db_comment.comment = comment["comment"] db_comment.creation_date = datetime.datetime.now() db_comment.user = comment_user db_comment.post = db_post db_comment.save() posts_file.close()