小编GTA*_*prx的帖子

如何解决 TypeError: on_delete must be callable on Django 模型?

突然我收到一个错误,说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 必须是可调用的。

python django cascade django-models

5
推荐指数
1
解决办法
8443
查看次数

进度条 - 类型错误:“模块”对象不可调用

我正在尝试使用进度条模块,但收到以下错误。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)

python python-3.x

5
推荐指数
1
解决办法
5977
查看次数

Insert string before file extension in another string

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"

c++ insert

1
推荐指数
1
解决办法
81
查看次数

默认使用最新版本的 Python

在我的 Debian 服务器上,如果我运行python -V它说它正在使用,Python 2.7.13即使我安装了 Python 3。

为什么现在不默认使用 Python 3?我正在尝试部署一个 Django 应用程序,它期待 Python 3。

python linux django debian python-3.x

0
推荐指数
2
解决办法
761
查看次数

标签 统计

python ×3

django ×2

python-3.x ×2

c++ ×1

cascade ×1

debian ×1

django-models ×1

insert ×1

linux ×1