求助!!!!编辑完 点击提交,/edit/action后报错:ValueError at /MyExcise/edit/action invalid literal for int() with base 10: ''
主要定位的问题是在def edit_action(request)这部分,编辑修改后,完全跳转不到文章列表页
def edit_action(request):
title = request.POST.get('title', 'TITLE')
content = request.POST.get('content','CONTENT')
article_id = request.POST.get('article_id', '0')
if str(article_id) == '0':
models.Acticle.objects.create(title=title,content=content)
articles = models.Acticle.objects.all()
return render(request, 'MyExcise/index.html', {'articles': articles})
article = models.Acticle.objects.get(pk=article_id)
article.title = title
article.content = content
article.save()
return render(request,'MyExcise/article_page.html', {'article': article})