小白变大师 2020-01-06 16:01 采纳率: 100%
浏览 400
已采纳

Django后台管理新建post保存出错

报错如下

TypeError at /admin/blog/post/add/
object of type 'int' has no len()
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/blog/post/add/
Django Version: 3.0.1
Exception Type: TypeError
Exception Value:

object of type 'int' has no len()
Exception Location: C:\Users\Administrator\Desktop\website\djangoenv\lib\site-packages\django\forms\models.py in has_changed, line 1354
Python Executable: C:\Users\Administrator\Desktop\website\djangoenv\Scripts\python.exe
Python Version: 3.6.5
Python Path:

['C:\Users\Administrator\Desktop\website\blog2020',
'C:\Users\Administrator\Desktop\website\djangoenv\Scripts\python36.zip',
'C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\DLLs',
'C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib',
'C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32',
'C:\Users\Administrator\Desktop\website\djangoenv',
'C:\Users\Administrator\Desktop\website\djangoenv\lib\site-packages']
Server time: 星期一, 6 一月 2020 15:56:18 +0800

源代码

def has_changed(self, initial, data):
if self.disabled:
return False
if initial is None:
initial = []
if data is None:
data = []
if len(initial) != len(data):
return True
initial_set = {str(value) for value in self.prepare_value(initial)}
data_set = {str(value) for value in data}
return data_set != initial_set

  • 写回答

1条回答 默认 最新

  • 'ゞBibo。 2020-01-06 16:07
    关注

    object of type 'int' has no len() 1354行你给int类型使用了len的方法

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退