突然我收到一个错误,说TypeError: on_delete must be callable.我不知道如何解决这个错误,因为我field=models.ForeignKey(default=1, on_delete='CASCADE', to='main.Category'),在我的代码中没有看到任何地方提到。
File "/home/arch/myproject/main/migrations/0014_auto_20191025_1154.py", line 6, in <module>
class Migration(migrations.Migration):
File "/home/arch/myproject/main/migrations/0014_auto_20191025_1154.py", line 47, in Migration
field=models.ForeignKey(default=1, on_delete='CASCADE', to='main.Category'),
File "/home/arch/.local/lib/python3.8/site-packages/django/db/models/fields/related.py", line 801, in __init__
raise TypeError('on_delete must be callable.')
Run Code Online (Sandbox Code Playgroud)
类型错误:on_delete 必须是可调用的。
我正在尝试使用进度条模块,但收到以下错误。TypeError: 'module' object is not callable我正在测试文档中的确切片段。
import time
import progressbar
for i in progressbar.progressbar(range(100)):
time.sleep(0.02)
Run Code Online (Sandbox Code Playgroud) I'm trying to insert a string into another string like you would with append() but rather than at the end I'd like to put it before the occurrence of ".xlsx".
string docName;
docName = "../Toyota Tacoma " + customer.toStdString() + " .xlsx";
if(sold = true){
docName = docName.append("(sold)");
}
doc.CreateDocument(docName);
Run Code Online (Sandbox Code Playgroud)
This code just appends "(sold)" after ".xlsx"
在我的 Debian 服务器上,如果我运行python -V它说它正在使用,Python 2.7.13即使我安装了 Python 3。
为什么现在不默认使用 Python 3?我正在尝试部署一个 Django 应用程序,它期待 Python 3。