简体   繁体   English

Django MySQL错误创建表

[英]Django MySQL error creating tables

I've a similar problem as this ticket raised on Django forum. 我和Django论坛上提出的这张票有类似的问题。 How do I solve this issue?? 我该如何解决这个问题?

I also have a User model extended, as follow:- 我还扩展了用户模型,如下: -

class Profile(models.Model):
    street_address = models.CharField(max_length=80, blank=True, null=True)
    city = models.CharField(max_length=80, blank=True, null=True)
    state = models.CharField(max_length=80, blank=True, null=True)
    zip = models.CharField(max_length=30, blank=True, null=True)
    country = models.CharField(max_length=50, blank=True, null=True)
    phone = models.CharField(max_length=50, blank=True, null=True)
    birth = models.DateField(blank=True, null=True)
    photo = models.ImageField(upload_to='media')
    user = models.OneToOneField(User,primary_key=True)

But I dont think the problem is with the model, because even if I remove the app containing the model from the INSTALLED_APPS list, and run the manage.py migrate command, it still throws the same errors, ie 但我不认为问题出在模型上,因为即使我从INSTALLED_APPS列表中删除包含模型的应用程序,并运行manage.py migrate命令,它仍然会抛出相同的错误,即

django.db.utils.OperationalError: (1005, "Can't create table 'db.#sql-456_113' (errno: 150)")

Without including any of the apps, it works fine. 没有包含任何应用程序,它工作正常。 Any lead will be really helpful. 任何领导都会非常有帮助。

Check the storage engine of your db tables. 检查数据库表的存储引擎。 As refered here old MySQL used MyISAM which is incompatible with actual InnoDB storage engine. 正如这里提到的旧的MySQL使用的MyISAM与实际的InnoDB存储引擎不兼容。 so, if your db has different storage engines for different tables and you try to make a Foreign Key, you will probably find this error. 因此,如果您的数据库具有不同表的不同存储引擎,并且您尝试创建外键,则可能会发现此错误。 At least, this was my case :) hope this helps someone 至少,这是我的情况:)希望这有助于某人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM