django - Django South数据迁移运行两次

标签 django django-south

我有一个迁移:

    ...

def forwards(self, orm):
    for p in products.models.Product.objects.all():
        new = cart.models.Product(title = p.title)
        new.save()

    def backwards():
        ...

但是,当我运行迁移时,它会在循环中运行两次。

最佳答案

你有没有

no_dry_run = True

在迁移定义中?

此外,我认为您应该使用orm.Product.objects.all()

关于django - Django South数据迁移运行两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2340448/

相关文章:

javascript - 调试 AllAuth : social account not logging user in despite connecting successfully

mysql - Django 南 : Combining "alter table"s for better performance?

mysql - Django 测试 - South 和 MySQL 的问题

python - Django South - 为已经填充表格的应用程序创建初始迁移

django 认证包 : 'auth' not registered as a namespace

django - 添加自定义 django 管理 View 的链接

django - pgpool2 负载平衡不起作用

python - 组和 channel 层使流程停止而不会引发异常

django - 如何在 Django 1.7 中重置迁移

python - 如何将 South 重新引入我的 Django 项目?