页面内容: <form action="{% url 'blog:edit_action'%}" methond="post"> {% csrf_token %} <lable>标题 <input type="text" name="title"> </lable> <br/> <lable>内容 <input type="text" name="content"> </lable> <br/> <input type="submit" value="提交" > </form>
python代码:
import blog.views as bv url(r'^edit/action$', bv.edit_action, name='edit_action'),
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});
提交后最后页面还是显示TITLE 和 CONTENT请教为什么呢?
888公里的追寻
产品经理不是经理
相关分类