小白变大师 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 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料