database - How do I migrate data from one model to another using South in Django? -
I created a new app that made it my own internal voting system, and to track it, a model named after the vote Was placed. I want to re-apply the voting system to my own app so that 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 in a different app.
How can I get two apps to participate in migration? Do I have access to both models? Unfortunately, in the original and isolated apps, a model name is now voted, so I should be aware of any confrontation.
Have you tried?
I will start by creating migration in either new or old apps which looks something like this. Class migration: def forward (self, orm): db.amename_table ('old_viet', 'new_witz') def backwards (auto, orm): db.rename_table ('new_vote' , 'Old_vote')
If that does not work, you can move each item in a loop with these lines:
def Forward (self, orm): [Old 'vote'] for the old. All (): # Create a new one with the old data model. = {'Old.vote' = {...}, 'new.vote' = {...},}
Note: You orm [...]
Currently, any model will be used outside the migrated app. Otherwise, the standard orm.Vote.objects.all ()
signaling works.
Comments
Post a Comment