Django:不同数据库中的 save() 方法
Django: save() method in a different database
我正在尝试将对象保存在非默认数据库中。我已经配置了第二个连接。
我知道为了得到对象是Class.objects.using('the_db').all
但是当我尝试 object.using('the_db').save()
时它不起作用。 (错误:"object has no attribute 'using'"。
我也试过 object.save('the_db')
但还是不行。
我怎样才能做到这一点?我找不到正确的语法。
尝试object.save(using='the_db')
相关 django 文档:https://docs.djangoproject.com/en/2.2/topics/db/multi-db/#moving-an-object-from-one-database-to-another
我正在尝试将对象保存在非默认数据库中。我已经配置了第二个连接。
我知道为了得到对象是Class.objects.using('the_db').all
但是当我尝试 object.using('the_db').save()
时它不起作用。 (错误:"object has no attribute 'using'"。
我也试过 object.save('the_db')
但还是不行。
我怎样才能做到这一点?我找不到正确的语法。
尝试object.save(using='the_db')
相关 django 文档:https://docs.djangoproject.com/en/2.2/topics/db/multi-db/#moving-an-object-from-one-database-to-another