跳回首页URL还是/blog/edit_action
编辑完成以后跳回首页URL还是/blog/edit_action,刷新重复提交了
编辑完成以后跳回首页URL还是/blog/edit_action,刷新重复提交了
2019-03-22
from django.http import HttpResponseRedirect #这一条要自己加上去
def edit_action(request):
title = request.POST.get('title','TITLE')
content = request.POST.get('content','CONTENT')
models.Article.objects.create(title=title,content=content)
articles = models.Article.objects.all()
#return render(request,'blog/index.html',{'articles':articles})#这一条是老师原本的内容,删掉
return HttpResponseRedirect('/blog/index',{'articles':articles})#换成这一条就可以了
举报