Django – get database configuration name in multi database settings

I’m very new in Python and Django programming. Recently I was writing a migration script to copy data across databases. Each database was in different machine and I’ve all the configurations in under different label like ‘default’, ‘staging’, ‘production’ etc.

While the migration was working almost fine, I was getting an error like the following during saving associated objects.

ValueError: Cannot assign "": instance is on database "staging", value is on database "default"

Continue reading →