python - 芹菜,关系“x_x”不存在
问题描述
查询期间 Celery 出现问题
这是我的代码:
from apps.teams.models import Team
@shared_task
@transaction.atomic
def createUserTenant():
addUserInTeam = Team.objects.create(user_id = 1)
这是错误:
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "teams_team" does not exist
LINE 1: INSERT INTO "teams_team" ("user_id") VALUES (1) RETURNING "t...
由于将相同的查询移动到我的视图时一切正常,但在芹菜中工作正常
解决方案
固定的 :
我必须选择当前模式,因为 celery 默认选择公共模式
with schema_context(current_schema):
addUserInTeam = Team.objects.create(user = CustomUser.objects.get(pk=userid))
推荐阅读
- c# - 如何使用 C# 在谷歌驱动器中创建文件夹而不重复?
- swift - 点击事件不会在动画图像视图上触发
- javascript - 如何在移动网络中录制高于 7700 Hz 的声音?
- javascript - 为什么 highcharts solidgauge 图表不按我预期的方式缩放?
- c# - 有没有办法解决 Assert.Istype() 失败问题?
- amazon-web-services - 在 ec2 (AWS) 上使用 RStudio 进行集群时发生意外崩溃
- laravel - 使用 clientOriginalName 保存多个上传
- javascript - 在javascript中将字符串转换为数组
- c# - C# ASP.net MVC Ajax MySQL DATATABLES 列搜索无法将搜索值传递给控制器
- php - 如何在PHP中删除数组中的值