문제

Specifically I'm looking for a schemamigration using Django, here is some of my code:

From

class Login(models.Model):
    username = models.CharField(max_length=30)
    password = models.CharField(max_length=30)
    email = models.EmailField()
    member_date = models.DateTimeField()

    def __unicode__(self):
        return self.username

To

class Login(models.Model):
    username = models.CharField(max_length=30)
    password = models.CharField(max_length=30)
    email = models.EmailField()
    member_date = models.DateTimeField(auto_now_add=True, blank=True) # changes here

    def __unicode__(self):
        return self.username
도움이 되었습니까?

해결책

What you're looking for is a way to do a data migration (specifically, a schemamigration). Please see the South Documentation for an easy tool to do this.

It essentially replaces syncdb for whatever apps you tell it to, and then can have it automatically write the migration. While this might seem like more work than it's worth at the beginning, once you get to the point where you have real data in your database, you'll find it's great to not have to delete (and then recreate) the tables each time you update your models.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top