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'
        db.rename_table('meetings_tag','meetings_remarktag')

    def backwards(self, orm):
        # Renaming model 'Tag' to 'RemarkTag'
        db.rename_table('meetings_remarktag','meetings_tag')

[T-SQL] Rename table or column

reference: http://msdn.microsoft.com/en-us/library/ms188351.aspx

Changes the name of a user-created object in the current database. This object can be a table, index, column, alias data type, or Microsoft .NET Framework common language runtime (CLR) user-defined type.

Syntax
sp_rename [ @objname = ] ‘object_name’ , [ @newname = ] ‘new_name’
[ , [ @objtype = ] ‘object_type’ ]

A. Renaming a table
The following example renames the SalesTerritory table to SalesTerr in the Sales schema.

USE AdventureWorks2008R2;
GO
EXEC sp_rename 'Sales.SalesTerritory', 'SalesTerr';
GO

B. Renaming a column
The following example renames the TerritoryID column in the SalesTerritory table to TerrID.

USE AdventureWorks2008R2;
GO
EXEC sp_rename 'Sales.SalesTerritory.TerritoryID', 'TerrID', 'COLUMN';
GO

C. Renaming an index
The following example renames the IX_ProductVendor_VendorID index to IX_VendorID.

USE AdventureWorks2008R2;
GO
EXEC sp_rename N'Purchasing.ProductVendor.IX_ProductVendor_VendorID', N'IX_VendorID', N'INDEX';
GO

D. Renaming an alias data type
The following example renames the Phone alias data type to Telephone.

USE AdventureWorks2008R2;
GO
EXEC sp_rename N'Phone', N'Telephone', N'USERDATATYPE';
GO