Django報錯ValueError: invalid literal for int() with base 10:
DJango報錯
ERROR:default:Traceback (most recent call last): File "/data/venv4archer/lib/python3.6/site-packages/django/core/handlers/base.py", line 132, in get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/data/venv4archer/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view return view_func(*args, **kwargs) File "/data/opt/archer_product_20181019/sql/views.py", line 1123, in modifydatasourceapply applyusername=datasourceapply.objects.filter(id=int(Datasourceapplyid)).values('user_name') ValueError: invalid literal for int() with base 10: ''
報錯原因:
post傳送過來的變數為空。
Datasourceapplyid = request.POST.get("datasourceid", "") print ('Datasourceapplyid', Datasourceapplyid) ValueError: invalid literal for int() with base 10: '' [26/Oct/2018 18:39:10] "POST /modifydatasourceapply/ HTTP/1.1" 500 12987 Datasourceapplyid
解決方法:
修復post變數傳入。
報錯時,var datasourceid = $("#datasource_id").val();寫成了var datasourceid = $("#datasourceid").val();,進而導致傳輸的變數為空值。
<form method="post" role="form"> {% csrf_token %} <div class="form-group"> <input type="hidden" class="form-control" id="datasource_id" name="datasourceid" value={{ datasourceDetail.id }} > </div> $("#btn-submitsql").click(function () { var datasourceid = $("#datasource_id").val(); var app_name = $("#app_name").val(); var env = $("#env").val(); var db_name = $("#db_name").val(); var db_privs = $("#db_privs").val(); var username = $("#username").val(); var port = $("#port").val(); var password = $("#password").val(); var ip_addr = $("#ip_addr").val(); $.ajax({ type: "post", async: false, url: "/modifydatasourceapply/", dataType: "json", data: { datasourceid: datasourceid, app_name: app_name, env: env, db_name: db_name, db_privs: db_privs, username: username, port: port, password: password, ip_addr: ip_addr },
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2217735/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- dbfread報錯ValueError錯誤解決方法Error
- 解決tensorboard報錯ValueError: Duplicate plugins for name projectorORBErrorPluginProject
- minio連線失敗報錯ValueError: path in endpoint is not allowedError
- React報錯之Element type is invalidReact
- Django 報錯 TemplateDoesNotExistDjango
- 使用yum報錯Your license is invalid.
- invalid conversion from ‘LRUCache*‘ to ‘int‘ [-fpermissive] /new的使用
- error: invalid type argument of unary ‘*‘ (have ‘int‘) *__first = __tmp;Error
- python: invalid value encountered in divide以及invalid value encountered in double_scalars報錯PythonIDE
- Django報錯django.utils.datastructures.MultiValueDictKeyErrorDjangoASTStructError
- 1.python報錯:TypeError: 'int' object is not subscriptablePythonErrorObject
- `jsonb` 報錯 `invalid input syntax for type timestamp with time zone ““JSON
- Maven專案報錯invalid LOC header (bad signature)MavenHeader
- Elasticsearch 6 建立索引報錯 invalid_index_name_exception Invalid index name [testDemo], must be lowercaseElasticsearch索引IndexException
- 【問題解決】remote: parse error: Invalid numeric literal at line 1, column 20,解決思路REMError
- MybatisPlus自帶方法報錯BindingException: Invalid bound statement (not found)MyBatisException
- kafka報錯:InvalidReceiveException: Invalid receive (size = 1195725856 larger than 104857600)KafkaException
- Mingw GCC 編譯OpenCV報錯: Project files may be invalidGC編譯OpenCVProject
- Django 報錯資訊總結Django
- SyntaxError: EOL while scanning string literal錯誤解決ErrorWhile
- Unable to unwrap data, invalid status [CLOSED]-服務端webSocket報錯服務端Web
- sqlplus / as sysdba報錯ORA-01017: invalid username/password; logon deniedSQLGo
- 報錯Invalid bound statement (not found): com.thxy.mapper.RoleMapper.insertRleAPP
- 小程式 · 報錯:Error: errCode: -501007 ,errMsg: Invalid Key Name (__keyPath)Error
- Django使用終端建立superuser報錯。Django
- yum安裝軟體報錯:Invalid configuration value: failovermethod=priority...AI
- linux解壓報錯gzip: stdin: invalid compressed data--format violatedLinuxORM
- Django(21)migrate報錯的解決方案Django
- Django2.2 報錯:UnicodeDecodeError 解決方法DjangoUnicodeError
- django3整合django-mdeditor報 ‘X-Frame-Options‘ 錯誤Django
- streamlit run執行報錯,Invalid value: File does not exist: XXX.py
- 【Azure Service Bus】建立 ServiceBus 的Terraform指令碼報錯GetAuthorizationRule: Invalid inputORM指令碼
- .net core中Grpc使用報錯:The remote certificate is invalid according to the validation procedure.RPCREM
- raksmart伺服器部署SSL報錯:ERR_CERT_COMMON_NAME_INVALID伺服器
- 華為支付購買token的verify介面報錯Token is expired or invalid
- std::sort 錯誤"Expression : invalid operator <"Express
- Python 錯誤 SyntaxError: invalid character in identifierPythonErrorIDE
- python去掉excel空格和換行,報錯'int' object has no attribute 'strip'PythonExcelObject