简体   繁体   English

操作错误1050 django makemigrations中的“表已存在”错误

[英]operational error 1050 Error “Table already exists” in django makemigrations

Hi am getting this wherever i try to make changes to my models or trying to migrate am using mysql and django 1.8.6 嗨,我正在尝试对我的模型进行更改或尝试使用mysql和django 1.8.6进行迁移

operational error 1050 Error “Table 'products_myproducts' already exists” just every time i make migrations 操作错误1050错误“表'products_myproducts'已经存在”,每次我进行迁移

 class Product(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL) managers = models.ManyToManyField(settings.AUTH_USER_MODEL,related_name="managers_product",blank=True) media = models.ImageField(blank=True,null=True, upload_to=download_media_location, storage=FileSystemStorage(location=settings.PROTECTED_ROOT)) title = models.CharField(max_length=30) description = models.TextField(default='',blank=True) slug= models.SlugField(blank=True,unique=True) price = models.DecimalField(max_digits=60,decimal_places=2,default=9.99) sale_active = models.BooleanField(default=False) sale_price = models.DecimalField(max_digits=60,decimal_places=2,default=6.99,null=True,blank=True) def __str__(self): return self.title 

also fo my products 也是我的产品

 class MyProducts(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL) products = models.ManyToManyField(Product,blank=True) def __str__(self): return "%s" %(self.products.count()) class Meta: verbose_name = "My Products" verbose_name_plural = "My Products" 

this error causes when you delete migrations directory from your apps and not dropping the database tables. 当您从应用程序中删除迁移目录而不删除数据库表时,会出现此错误。
if data on the database is important, just backup form data and then drop the database tables. 如果数据库上的数据很重要,只需备份表单数据然后删除数据库表。
then delete all migrations directory from each app and makemigration then migrate again and import your data. 然后从每个应用程序中删除所有迁移目录,然后再迁移,然后再次迁移并导入数据。

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

相关问题 MySQL 错误 1146 和 1050 - 表不存在且表已存在 - MySQL Error 1146 and 1050 - Table does not exists and Table already exists 为什么会出现此错误“django.db.utils.OperationalError: (1050, “Table 'someTable' already exists”)” - Why getting this error "django.db.utils.OperationalError: (1050, "Table 'someTable' already exists")" Django 1.8操作错误:没有这样的表 - Django 1.8 Operational error : no such table python - Django 操作错误,无此表 - python - Django Operational Error, No such table 操作错误 - 没有这样的表 - Django,mptt - operational error - no such table - Django, mptt Python Django 操作错误,没有这样的表 - Python Django Operational error, no such table django.db.utils.InternalError: (1050, “表 'django_content_type' 已经存在”) - django.db.utils.InternalError: (1050, "Table 'django_content_type' already exists") Django:html模板的操作错误,“没有这样的表” - Django: Operational Error with html template and “no such table” django.db.utils.OperationalError:(1050,“表‘profiles_category’已经存在”) - django.db.utils.OperationalError: (1050, "Table 'profiles_category' already exists") django makemigrations 错误“没有这样的列” - django makemigrations error “no such column”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM