django.db.utils.DatabaseError 单独启动个脚本调用django的orm报错

来源:7-10 有没有方法既可以使用外键又不定死外键类型?

慕的地7158155

2022-03-11

我单独使用一个脚本去启动django的orm,结果报错了。

django.db.utils.DatabaseError: DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias ‘default’ was created in thread id 17060 and this is thread id 2609190477672.

图片描述

图片描述

图片描述

写回答

1回答

bobby

2024-12-27

不能单独启动某个文件, orm没法初始化,想要单独启动 需要调用 django的setup

0
0

Django+ xadmin 开发在线教育网站

一套通用的技术组合拳,助你解决大部分Python类网站后端问题

1931 学习 · 2170 问题

查看课程