Postgres 9.x

问题描述 投票:1回答:2
Let's say I created a

instance, associated it with a

and saved it:

class Buildings(BaseModel):
    number = models.CharField(max_length=25)

class TestGeneric(models.Model):

    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey()

Now I rename TestGeneric to Building and run

TestGeneric.objects.create(content_object=Building.objects.first())

. I'm prompted BuildingsI choose yes. I then run Building and get:makemigrationsRegardless of what I answer Django automatically will create a new row in Did you rename the app.Buildings model to Building? [y/N]

with migrate as the name and label. Is there any way to just rename the

The following content types are stale and need to be deleted:

app | buildings

Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.

so that all of my TestGeneric rows aren't blown away?django_content_type building ContentTypeSetup: Django 1.7 新的django_content_type被创建,而不是重命名旧的记录。

python django django-migrations
2个回答
© www.soinside.com 2019 - 2024. All rights reserved.