Easiest way to rename a model using Django/South?
        Posted  
        
            by vaughnkoch
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by vaughnkoch
        
        
        
        Published on 2010-05-19T05:02:33Z
        Indexed on 
            2010/05/19
            5:30 UTC
        
        
        Read the original article
        Hit count: 324
        
Hi everyone, I've been hunting for an answer to this on South's site, google, and SO, but couldn't find a simple way to do this.
I want to rename a Django model using South. Say you have the following:
class Foo(models.Model):
    name = models.CharField()
class FooTwo(models.Model):
    name = models.CharField()
    foo = models.ForeignKey(Foo)
and you want to convert Foo to Bar, namely
class Bar(models.Model):
    name = models.CharField()
class FooTwo(models.Model):
    name = models.CharField()
    foo = models.ForeignKey(Bar)
To keep it simple, I'm just trying to change the name from Foo to Bar, but ignore the 'foo' member in FooTwo for now.
What's the easiest way to do this using South?
a) I could probably do a data migration, but that seems pretty involved.
b) Write a custom migration, e.g. db.rename_table('city_citystate', 'geo_citystate'), but I'm not sure how to fix the foreign key in this case.
c) An easier way that you know?
Thanks!
© Stack Overflow or respective owner