I created a Django app that had its own internal voting system and a model called Vote to track it. I want to refactor the voting system into its own app so I can reuse it. However, the original app is in production and I need to create a data migration that will take all the Votes and transplant them into the separate app.
How can I get two apps to participate in a migration so that I have access to both their models? Unfortunately, the original and separate apps both have a model named Vote now, so I need to be aware of any conflicts.
Have you tried db.rename_table?
I would start by creating a migration in either the new or old app that looks something like this.
If that does not work you can migrate each item in a loop with something along these lines:
Note: You must use
orm[...]to access any models outside the app currently being migrated. Otherwise, standardorm.Vote.objects.all()notation works.