我的应用程序创建了一个有错误的对象,用户插入了一个字符串(我相信),但字段是十进制的。你知道吗
我知道表单会阻止它,但是插入发生在post\u save decorator上,现在我无法访问对象、更新或删除它。你知道吗
comandas_antecipadas = ComandaAntecipado.objects.all()
comandas_antecipadas
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\projetos\barzim\venv\lib\site-packages\django\db\models\query.py", line 244, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "C:\projetos\barzim\venv\lib\site-packages\django\db\models\query.py", line 268, in __iter__
self._fetch_all()
File "C:\projetos\barzim\venv\lib\site-packages\django\db\models\query.py", line 1186, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "C:\projetos\barzim\venv\lib\site-packages\django\db\models\query.py", line 63, in __iter__
for row in compiler.results_iter(results):
File "C:\projetos\barzim\venv\lib\site-packages\django\db\models\sql\compiler.py", line 1009, in apply_converters
value = converter(value, expression, connection)
File "C:\projetos\barzim\venv\lib\site-packages\django\db\backends\sqlite3\operations.py", line 254, in converter
return create_decimal(value).quantize(quantize_value, context=expression.output_field.context)
TypeError: argument must be int or float
comandas_antecipadas.count()
11
comandas_antecipadas[9]
<ComandaAntecipado: ComandaAntecipado object (120)>
comandas_antecipadas[10]
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\projetos\barzim\venv\lib\site-packages\django\db\models\query.py", line 302, in __getitem__
qs._fetch_all()
File "C:\projetos\barzim\venv\lib\site-packages\django\db\models\query.py", line 1186, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "C:\projetos\barzim\venv\lib\site-packages\django\db\models\query.py", line 63, in __iter__
for row in compiler.results_iter(results):
File "C:\projetos\barzim\venv\lib\site-packages\django\db\models\sql\compiler.py", line 1009, in apply_converters
value = converter(value, expression, connection)
File "C:\projetos\barzim\venv\lib\site-packages\django\db\backends\sqlite3\operations.py", line 254, in converter
return create_decimal(value).quantize(quantize_value, context=expression.output_field.context)
TypeError: argument must be int or float
当您试图在控制台中显示对象时,问题就出现了。所以,别那么做。直接删除即可:
相关问题 更多 >
编程相关推荐