当前位置: 首页>>代码示例>>Python>>正文


Python CommentForm.save方法代码示例

本文整理汇总了Python中blog.forms.CommentForm.save方法的典型用法代码示例。如果您正苦于以下问题:Python CommentForm.save方法的具体用法?Python CommentForm.save怎么用?Python CommentForm.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在blog.forms.CommentForm的用法示例。


在下文中一共展示了CommentForm.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: edit_comment

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
def edit_comment(request, comid):
    context=RequestContext(request)
    com=Comment.objects.get(pk=comid)
    form= CommentForm(request.POST or None, instance=com)
    if form.is_valid():
       form.save()
       return added(request)

    return render_to_response('blog/edit_comment.html', {'form':form, 'comid':comid}, context)
开发者ID:umudoff,项目名称:blog_project,代码行数:11,代码来源:views.py

示例2: post

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
 def post(self, request, pk):
     # return HttpResponse(request.POST['entry_id'])
     form = CommentForm(request.POST, request.FILES)
     if form.is_valid():
         form.save()
         return HttpResponse("Your comment submitted successfully")
     else:
         self.kwargs["forms"] = form
         return self.render_to_response(self.get_context_data(forms=form))
开发者ID:tdn1234,项目名称:unittest,代码行数:11,代码来源:views.py

示例3: forms

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
def forms(request, article_id):
        if request.POST:
            new_form = CommentForm(request.POST)
            if new_form.is_valid():
                print(request.POST, new_form.errors, new_form.cleaned_data)
                comment = new_form.save(commit=False)
                comment.comment_article = Article.objects.get(id=article_id)
                new_form.save()
        return redirect('/article/get/%s/' % article_id)
开发者ID:Tadjo,项目名称:DjangoThirstProject,代码行数:11,代码来源:views.py

示例4: post

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
    def post(self, request, *args, **kwargs):
        self.object = self.get_object()
        form = CommentForm(object=self.object, data=request.POST)

        if form.is_valid():
            form.save()
            return HttpResponseRedirect(self.object.get_absolute_url())

        context = self.get_context_data(object=self.object, form=form)
        return self.render_to_response(context)
开发者ID:jDebu,项目名称:community,代码行数:12,代码来源:views.py

示例5: addcomment

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
def addcomment(request, article_id):
    if request.POST and ('pause' not in request.session):
        form = CommentForm(request.POST)
        if form.is_valid:
            comment = form.save(commit=False)  # запрещаем автосохранение комментария
            comment.comment_article = Articles.objects.get(id=article_id)
            form.save()
            request.session.set_expiry(60)
            request.session['pause'] = True
    return redirect('/articles/get/%s/' % article_id)  # редирект на ту же статью на которой оставлен коммент
开发者ID:doncu,项目名称:manage_task,代码行数:12,代码来源:views.py

示例6: post

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
 def post(self, request):
     a=request.POST.get('post')
     print a
     if request.GET:
         print "get"
     if request.POST:
         print "post"
     create_comment = CommentForm(request.POST)
     if create_comment.is_valid():
         create_comment.save()
     return HttpResponseRedirect("/blog/"+str(a)+"/mainblog2/")
开发者ID:kmpoudel,项目名称:ArticleNew,代码行数:13,代码来源:views.py

示例7: addcomment

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
def addcomment(request, article_id):
    return_path = request.META.get('HTTP_REFERER', '/')
    if request.POST and ("pause" not in request.session):
        form = CommentForm(request.POST)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.comment_article = Article.objects.get(id=article_id)
            form.save()
            request.session.set_expiry(60) #ограничение ввода комментариев
            request.session['pause'] = True
    return redirect(return_path)
开发者ID:Shatki,项目名称:TonerProject,代码行数:13,代码来源:views.py

示例8: addcomment

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
def addcomment(request, article_id):
    if request.POST and ("pause") not in request.session:
        form = CommentForm(request.POST)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.comments_article = Article.objects.get(id=article_id)
            form.save()
            request.session.set_expiry(60)
            request.session["pause"] = True

    return redirect("/articles/get/%s/" % article_id)
开发者ID:Scaurus,项目名称:myblog,代码行数:13,代码来源:views.py

示例9: comment_edit

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
def comment_edit(request, entry_pk, pk):
    comment = get_object_or_404(Comment, pk=pk)

    if request.method == "POST":
        form = CommentForm(request.POST, instance=comment)
        if form.is_valid():
            form.save()
            return redirect("blog.views.detail", entry_pk)
    else:
        form = CommentForm(instance=comment)
    return render(request, "form.html", {"form": form})
开发者ID:jungkeuny,项目名称:jklog,代码行数:13,代码来源:views.py

示例10: comment_edit

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
def comment_edit(request, post_pk, pk):
    # comment = Comment.objects.get(pk=pk)
    comment = Comment.get_object_or_404(Comment, pk=pk)
    if request.method == 'POST':
        form = CommentForm(request.POST, instance=comment)
        if form.is_valid():
            form.save()
            return redirect('blog,.post_detail', post_pk)
    else:
        form = CommentForm(instance=comment)
    return render(request, 'blog/comment_form.html', {'form': form,
    })
开发者ID:EunkyungJo,项目名称:ubuntu,代码行数:14,代码来源:views.py

示例11: comment_new

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
def comment_new(request, post_pk):

    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            form.save()
            messages.debug(request, '새로운 댓글을 등록했습니다.')
            return redirect('post_detail', post_pk)
    else:
        form = CommentForm()
    return render(request, 'blog/comment_form.html', {'form':form,
        })
开发者ID:sonclara,项目名称:programmming,代码行数:14,代码来源:views.py

示例12: comment_edit

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
def comment_edit(request, id, comment_id):
    comment = get_object_or_404(Comment, id=comment_id)
    if request.method == 'POST':
        form = CommentForm(request.POST, request.FILES, instance=comment)
        if form.is_valid():
            form.save()
            return redirect('blog:post_detail', id)
    else:
        form = CommentForm(instance=comment)
    return render(request, 'blog/post_form.html', {
        'form': form,
    })
开发者ID:jeeyun617,项目名称:shake,代码行数:14,代码来源:views.py

示例13: comment_form

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
def comment_form(request):
    if request.method == 'POST':
        form = CommentForm(request.POST)

        if form.is_valid():
            form.save(commit=True)
            return index (request)
        else:
            print (form.errors)
    else:
        form = CommentForm()

    return render(request, 'blog/comment_form.html', {'form':form})
开发者ID:pleasureinblues,项目名称:opinion-blog,代码行数:15,代码来源:views.py

示例14: comment_edit

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
def comment_edit(request, post_pk, pk):
    # comment = Comment.objects.get(pk=pk)
    # comment = get_object_or_404(Comment, pk=pk)
    comment = request.instance

    if request.method == "POST":
        form = CommentForm(request.POST, instance=comment)
        if form.is_valid():
            form.save()
            return redirect(comment.post)
    else:
        form = CommentForm(instance=comment)
    return render(request, "blog/comment_form.html", {"form": form})
开发者ID:frmh0313,项目名称:example,代码行数:15,代码来源:views.py

示例15: comment_edit

# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import save [as 别名]
def comment_edit(request, post_pk, pk):
    comment = get_object_or_404(Comment, pk=pk)

    if request.method == 'POST':
        form = CommentForm(request.POST, instance=comment)
        if form.is_valid():
            form.save()
            messages.success(request, 'updated comment')
            return redirect('blog.views.detail', post_pk)
    else:
        form = CommentForm(instance=comment)
    return render(request, 'form.html', {
        'form': form,
    })
开发者ID:plusbeauxjours,项目名称:pystagram_test,代码行数:16,代码来源:views.py


注:本文中的blog.forms.CommentForm.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。