• 手机版

    扫码体验手机版

  • 微信公众号

    扫码关注公众号

国内首家协议开发

软芯音视解码保护平台

在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

点击新文章提交之后出现ValueError at /blog/edit/action

django:2.1.0  pycharm:2018.2invalid literal for int() with base 10: ''Request Method:POSTRequest URL:http://127.0.0.1:8000/blog/edit/actionDjango Version:2.1.1Exception Type:ValueErrorException Value:invalid literal for int() with base 10: ''Exception Location:C:\Users\89758\AppData\Local\Programs\Python\Python37\lib\site-packages\django-2.1.1-py3.7.egg\django\db\models\fields\__init__.py in get_prep_value, line 965Python Executable:C:\Users\89758\AppData\Local\Programs\Python\Python37\python.exePython Version:3.7.0Python Path:['D:\\Python\\myblog', 'C:\\Users\\89758\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip', 'C:\\Users\\89758\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\89758\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\89758\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Users\\89758\\AppData\\Roaming\\Python\\Python37\\site-packages', 'C:\\Users\\89758\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages', 'C:\\Users\\89758\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\django-2.1.1-py3.7.egg', 'C:\\Users\\89758\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\pytz-2018.5-py3.7.egg']Server time:星期二, 25 九月 2018 02:49:36 +0000



edit_page:

        Edit Page {% csrf_token %}    {% if article %}                文章标题                           
        文章内容                           
{% else %}                文章标题                           
        文章内容                           
{% endif %}   

views:
from django.shortcuts import renderfrom . import modelsfrom django.http import HttpResponsefrom django.http import HttpResponseRedirect# Create your views here.def index(request):    article = models.Articel.objects.all()    return render(request, 'index.html', {'article':article})def article_page(request,article_id):    article= models.Articel.objects.get(pk=article_id)    return  render(request,'article_page.html',{'article':article})def edit_page(request,article_id):    if str(article_id)=='0':        return render(request,'edit_page.html')    article= models.Articel.objects.get(pk=article_id)    return  render(request,'edit_page.html',{'article':article})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 article_id == '0':        models.Articel.objects.create(title=title, content=content)        articles = models.Articel.objects.all()        return render(request,'index.html', {'articles': articles})    article = models.Articel.objects.get(pk=article_id)    article.title = title    article.content = content    article.save()    return  render(request,'article_page.html',{'article':article})

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

发新帖

发布任务需求已有1031167位用户正在使用天盟网服务

发布分类: *
任务预算: *
需求内容: *
手机号码: *
任务商家报价为
  • 预算价 :
  • 成交价 :
  • 完工期 :
  • 质保期 :

* 最终任务项目以服务商报价、双方协商为准!