新建页面完成后跳转到主页,页面是主页,但url显示的是localhost:8000/blog/edit_action而不是localhost:8000/blog/index,刷新会再次新建一条博客
新建页面完成后跳转到主页,页面是主页,但url显示的是localhost:8000/blog/edit_action而不是localhost:8000/blog/index,刷新会再次新建一条博客
新建页面完成后跳转到主页,页面是主页,但url显示的是localhost:8000/blog/edit_action而不是localhost:8000/blog/index,刷新会再次新建一条博客
2017-08-07
重定向一下:
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',{'articles':articles})
举报