【问题标题】:django South failing with self referencing modelsdjango South 使用自引用模型失败
【发布时间】:2012-08-21 17:20:35
【问题描述】:

我有一个自引用模型

class Category(models.Model):
category_name= models.CharField(max_length=255)
parent_category= models.ForeignKey('self',null=True,blank=True)
category_user_number=models.IntegerField(null=True, blank=True)
def __unicode__(self):
    return self.category_name

当我使用 south 时,此模型在本地工作,但当我上传到 heroku parent_category 时出现错误

column mysite_category.parent_category_id does not exist

【问题讨论】:

    标签: django heroku


    【解决方案1】:

    推送到heroku时需要运行heroku run python manage.py migrate

    【讨论】:

    • 我做了,但它给了我这个错误django.db.utils.DatabaseError: column "demo" of relation "uTriga_category" does not exist demo 是我之前使用的一个属性,但已将其删除。我删除了演示,编写了上面的新代码,甚至删除了heroku上的应用程序并重新开始。只是当我将parent_category 更改为除自引用之外的任何其他字段时。它适用于heroku。
    • 是否有移除demo属性的迁移?
    • 不,我刚刚删除了 heroku 上的应用程序,从模型中删除了演示并再次创建了应用程序...重新开始。还是我错过了什么?
    • 它可能仍然存在于数据库中。如果您查看您的迁移文件,您是否仍然看到在您的模型上定义的 demo 属性?
    • 不是我很久以前删除了migration文件夹中的demo相关文件
    猜你喜欢
    • 1970-01-01
    • 2013-06-28
    • 1970-01-01
    • 2012-05-09
    • 1970-01-01
    • 2015-04-12
    • 2016-05-10
    • 2013-05-14
    • 2012-03-08
    相关资源
    最近更新 更多