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 settings.py 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"
Recently this problem troubled me a lot. All time I try to activate my plugin, I get the following error:
The plugin generated 1186 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
After several attempts of debugging, I failed to understand why it is coming. The mysterious thing was that, this error was not coming for all WordPress installations!
Today, I decided to read the core files those are responsible for activating and/or deactivating the plugins. When I was reading wp-admin/includes/plugin.php, I saw a action hook ‘activated_plugin’ is available just before throwing the error. I believed, if I monitor what is happening here, I can know the reason of the error. So I wrote a small function to save the errors like: