Django - 在特定数据库中创建对象



要将模型保存到我的'not_default_db'我正在使用:

p = Person(name='James')
p.save(using='not_default_db') 

但是使用Model.create((将模型保存在默认数据库中:

Person.objects.create(name='James')

是否可以在特定的数据库上使用Model.create((

尝试使用 queryset 的using()方法:

Person.objects.using('not_default_db').create(name='James')

最新更新