Reputation: 980
I'm trying to save an object in a non-default database. I have already configured a second connection.
I know that in order to get objects it is Class.objects.using('the_db').all
But when I try object.using('the_db').save()
it doesn't work. (Error: "object has no attribute 'using'".
I also tried object.save('the_db')
but it also does not work.
How can I achieve this? I couldn't find the correct syntax.
Upvotes: 3
Views: 4403
Reputation: 1937
Try object.save(using='the_db')
Relative django documentation: https://docs.djangoproject.com/en/dev/topics/db/multi-db/#moving-an-object-from-one-database-to-another
Upvotes: 9