我在我的django项目中使用mysql。在model.py中我更改了我的主键。因为我收到了错误。
django.db.utils.OperationalError:(1025,"重命名' ./ newdb时出错 /#SQL-4ac_29'到' ./ newdb / companies2_album' (错误:150)")
从model.py我删除了表和相应的表。现在我没有任何歌曲表。
from __future__ import unicode_literals
from django.db import models
class Stock(models.Model):
ticker=models.CharField(max_length=10)
open=models.FloatField()
close=models.FloatField()
volume=models.IntegerField()
def __str__(self):
return self.ticker
class Stock2(models.Model):
ticker = models.CharField(max_length=10)
open = models.FloatField()
close = models.FloatField()
volume = models.IntegerField()
def __str__(self):
return self.ticker
'''
(deleted)
class Band(models.Model):
id = models.AutoField(primary_key=True)
ticker = models.CharField(max_length=10)
genre=models.CharField(max_length=10)
formationyear=models.IntegerField()
country=models.CharField(max_length=20)
lineup = models.CharField(max_length=80)
image = models.ImageField(upload_to="bandimages")
def __str__(self):
return self.ticker
class Album(models.Model):
id=models.AutoField(primary_key=True)
name=models.CharField(max_length=20)
'bandid=models.ForeignKey(Band,on_delete=models.CASCADE)'
releaseyear=models.IntegerField()
songscount= models.IntegerField()
image = models.ImageField()
def __str__(self):
return self.name
class Song(models.Model):
id = models.AutoField(primary_key=True)
name=models.CharField(max_length=20)
'albumid=models.ForeignKey(Album,on_delete=models.CASCADE)'
lyric=models.CharField(max_length=200)
like=models.IntegerField()
dislike=models.IntegerField()
utubelink=models.CharField(max_length=100)
def __str__(self):
return self.name
(deleted)
'''
我仍然收到此错误。
我无法理解它是如何发生的。我也更改了数据库。重新安装mysqlserver.But没有什么可以解决这个问题。