Django查詢models物件報錯:TypeError: __str__ returned non-string (type decimal.Decimal)
執行環境: python 3.6.1Django 1.11.3
modles.py 添加了如下的物件:
class ApplStockPrice(models.Model): Date = models.CharField(max_length=20) Open = models.DecimalField(max_digits=20,decimal_places=5) High = models.DecimalField(max_digits=20,decimal_places=5) Low = models.DecimalField(max_digits=20,decimal_places=5) Close = models.DecimalField(max_digits=20,decimal_places=5) Adj_Close = models.DecimalField(max_digits=20,decimal_places=6) Volume = models.DecimalField(max_digits=20,decimal_places=2) def __str__(self): return self.Close
mysql資料庫中的資料:
錯誤原因解析:
函式返回的是str,但是之前傳的值是Decimal。
解決方式一:
手工修改 __str__() 函式;
解決方式二:
類似的錯誤:
TypeError: __str__ returned non-string (type tuple)相關推薦
Django查詢models物件報錯:TypeError: __str__ returned non-string (type decimal.Decimal)
執行環境: python 3.6.1Django 1.11.3 modles.py 添加了如下的物件: class ApplStockPrice(models.Model): Date =
django Error during template rendering,TypeError: __str__ returned non-string (type int)
初學django時在django 站點管理中遇到的錯誤,其實是個很簡單的問題,今天把問題解決方案分享一下,希望可以對遇到同樣問題的朋友有所幫助。 問題描述:在django站點管理中,在某個物件的列表中
Django 報錯:__str__ returned non-string (type NoneType) 如何解決?
當我們在使用者users的應用中的model下,對內部的users表進行擴充時 __str__ 如果返回的東西是一個預設值是空或者是約束可以為空的時候 進入後臺操作時會產生這樣的報錯 __str__ returned non-string (type NoneType
Django rest framework:__str__ returned non-string (type NoneType) 真正原因
問題 field __str__ span 是我 字段 max 一個 self. 出錯原因: 用戶表是Django中核心的表,當這個表類字段中有一個這樣的函數 def __str__(self): return self.name 在Django用戶表設
TypeError at /goods/ __str__ returned non-string (type NoneType)
今天在學習Django專案時,使用Djangorestframework出現了以下錯誤: 問題原因 由於user的model的name引數可以為空導致的 class UserProfile(Abst
【Python】django報錯:TypeError: __init__() missing 1 required positional argument: 'on_delete'解決辦法
錯誤程式碼: from __future__ import unicode_literals from django.db import models from django.utils.encoding import python_2_unicode_compatible
Django報錯:TypeError: render() got an unexpected keyword argument 'renderer'
這是由於整合DjangoUeditor時出錯: 需要修改虛擬環境下的:boundfield.py檔案: .virtualenvs/虛擬環境檔案/lib/python3.5/site-packages/django/forms/boundfield.py 89 return wi
python3報錯:TypeError: can't concat bytes to str
erro ring blog error: python3 con decode 解決方法 error 有時會報錯這個:TypeError: Can‘t convert ‘bytes‘ object to str implicitly 解決方法:使用字節碼的decode()
Python_報錯:TypeError: Tuple or struct_time argument required
line 元祖 recent ror color time 但是 -c fcc 報錯:TypeError: Tuple or struct_time argument required 原因:時間戳和格式化處理時間不能直接使用會報錯 上代碼: import time t
報錯:TypeError: 'NoneType' object is not callable問題解決
報錯:TypeError: ‘NoneType’ object is not callable問題解決方法 def dec(function): print("start...") function() print("end...") #修飾器 @dec def
python報錯:TypeError: slice indices must be integers or None or have an __index__ method
宣告:本文為博主原創文章,不可轉載 https://blog.csdn.net/jjddss/article/details/73469104 在使用Python進行矩陣操作時,當內部含有除法時,會產生錯誤: TypeError: slice indices must be integers
hibernate創建本地查詢後進行查詢的時候報錯: could not execute query;列名無效
遇到 註解 ransient 映射類 日誌信息 數據 字段 數據庫 get 今天在走數據下發的時候遇到了一個問題: 創建一個sql語句(sql語句很簡單) 創建了一個本地查詢,執行這個sql語句 結果報錯:could not execute query;列名無效 先檢查數據
查詢docker狀態報錯:docker dead but pid file exists
背景 在CentOS 6上為了使用docker,於是升級了核心到3.10版本,然後安裝repo源和docker元件, yum install epel-release yum install docke
python 之報錯:TypeError: write() argument must be str, not bytes
在用 pickle.dump() 儲存二進位制檔案時,一直報錯,程式如下: with open(os.path.join(FLAGS.train_data_dir, 'files.log'), 'w') as f: pickle.dump([training_paths, testing_
faster rcnn報錯:TypeError: slice indices must be integers or None or have an __index__ method
https://blog.csdn.net/qq_27637315/article/details/78849756 faster rcnn報錯:TypeError: slice indices must be integers or None or have an __index__ method
React報錯:TypeError: Super expression must either be null or a function
今天搭建一個專案主頁,出現TypeError: Super expression must either be null or a function錯誤,如下圖: 這個問題說明了我們extends的那個函式沒有匯出相應的屬性,注意看我們錯誤提示Footer.js檔案,我們出錯語句是ex
【python】報錯:TypeError: 'builtin_function_or_method' object is unsubscriptable的解決方法
出現這個報錯的原因其實很簡單,就是將小括號'()'寫成了中括號‘[]' 下面來看一個例子: 當一個字典裡面嵌套了字典和列表的時候,再通過字典多層呼叫,將get函式後的小括號寫成了中括號。如下面程式碼第二行: 1.def lookup(data,label,name):
Angular 懶載入報錯:TypeError:undefined is not a function
前言 Angular日常採坑 在Angular中嘗試進行懶載入時,遇到以下錯誤: TypeError:undefined is not a function 導致原因 在Ap
【Python】關於鍵盤鍵入值、str的與或非問題?【報錯:TypeError: unsupported operand type(s) for |: 'str' and 'str'】
error 運算符 字符 符號 str == 條件 col one 參考 【報錯:TypeError: unsupported operand type(s) for |: ‘str‘ and ‘str‘】 在進行鍵入值比較的時候,想要用“或&rd
mysql報錯:java.sql.SQLException: Incorrect string value: ‘xE4xB8x80xE6xACxA1...‘ for column ‘excelName‘ at row 1
play order none png cor lin mysql報錯 mys splay 一、問題 用Eclipse做項目時候報錯 java.sql.SQLException: Incorrect string value: ‘\xE4\xB8\x80\xE6\