Creating MySQL Django Error Tables

I have the same issue as this ticket raised on the Django forum. How to solve this problem?

I also have a User model as shown below: -

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 don’t think that the problem is related to the model, because even if I delete the application containing the model from the INSTALLED_APPS list and run the manage.py migrate command, it still throws the same errors, i.e.

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

Without turning on any applications, the application works fine. Any guidance would be really helpful.

+3
python django mysql
source share
1 answer

Check the storage mechanism of your db tables. As mentioned here, old MySQL used MyISAM, which is not compatible with the actual InnoDB storage engine. therefore, if your db has different storage mechanisms for different tables, and you are trying to make a foreign key, you will probably find this error. At least that was my business :) I hope this helps someone

+2
source share

All Articles