开发者

Django South "myapp.foo" already exists" error with initial migration

I have an already existing app with alot of database entries.

class Foo(models.Model):
    value = models.TextField(u"V开发者_JAVA技巧alue")

For this I do this:

python manage.py schemamigration myapp --initial
python  manage.py migrate myapp

I change the model to such:

class Foo(models.Model):
    value = models.TextField(u"Value")
    live = models.BooleanField(u"Live", default=False)
    creation_time = models.DateTimeField("Creation Time", auto_now_add=True, null=True, blank=True)

and migrate:

python manage.py schemamigration myapp --auto
python  manage.py migrate myapp

I get django.db.utils.DatabaseError: relation "myapp.foo" already exists error.

I have already checked this question but --fake doesn't seem to be supported via South anymore.


Your models look invalid to me, though I'd be surprised if that's what's actually causing the problem.

It looks like your first argument is intended to be the verbose_name attribute, your model should probably look like this:

class Foo(models.Model):
    value = models.TextField(verbose_name = u"Value")
    live = models.BooleanField(verbose_name = u"Live", default=False)
    creation_time = models.DateTimeField(verbose_name = u"Creation Time", auto_now_add=True, null=True, blank=True)

(you also forgot the u before the verbose_name for creation_time).

Meanwhile, --fake is definitely still supported (see the docs), what error are you getting when you try and run it?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜