Rename Model(Table) in Django South Migration

When you change the name of model and create a migration file, you will see the code like “delete table, create table, and create relationship”.
It means you will lose all data in the previous model. However, here’s a simple way to rename model(table) with data.
Change the migration file as below or you may create yours.

class Migration(SchemaMigration):

    def forwards(self, orm):
        # Renaming model 'Tag' to 'RemarkTag'

    def backwards(self, orm):
        # Renaming model 'Tag' to 'RemarkTag'

One thought on “Rename Model(Table) in Django South Migration

  1. Pingback: Django migration strategy for renaming a model and relationship fields - ExceptionsHub

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s