gpt4 book ai didi

django - 在数据迁移中访问模型管理器方法

转载 作者:行者123 更新时间:2023-12-03 18:32:51 24 4
gpt4 key购买 nike

我正在尝试为我的一个应用程序制定数据迁移。我正在使用这里提到的声誉系统 - django-reputation

在我的 forward 方法中,我有以下代码 -

orm['reputation.reputation'].objects.log_reputation_action(user = user_x, originating_user = user_y, action_value = 10, target_object = sample_obj)

但是在运行迁移时,我收到以下错误 -
AttributeError: 'Manager' object has no attribute 'log_reputation_action'

我已经卡住了数据迁移中的 reputation 应用程序。请让我知道我在这里做错了什么。

提前致谢。

最佳答案

看起来这是不可能的。

South documentation :

You can do a lot more with this inside a data migration; any model can be available to you. The only caveat is that you won’t have access to any custom methods or managers on your models, as they’re not preserved as part of the freezing process (there’s no way to do this generally); you’ll have to copy any code you want into the migration itself. Feel free to make them methods on the Migration class; South ignores everything apart from forwards and backwards.

关于django - 在数据迁移中访问模型管理器方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27092440/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com