[英]migrate error 'No migration to apply' also not add table in postgresql in django
我正在尝试为电子商务站点创建模型,但是在尝试迁移终端时进行迁移后显示“无迁移应用”但是当我检查数据库时没有新表。 请帮我。
`
from django.db import models
from django.utils import timezone
# Create your models here.
class Collection(models.Model):
name = models.CharField(max_length=200, null=True)
def __str__(self):
return self.name
class ProductCategory(models.Model):
name = models.CharField(max_length=100, null=True)
def __str__(self):
return self.name
class Brand(models.Model):
name = models.CharField(max_length=100, null=True)
def __str__(self):
return self.name
class Color(models.Model):
color = models.CharField(max_length=50, null=True)
def __str__(self):
return self.color
class Size(models.Model):
size = models.CharField(max_length=20, null=True)
def __str__(self):
return self.size
class Products(models.Model):
name = models.CharField(max_length=200, null=True)
for_people = models.ForeignKey(Collection, on_delete=models.CASCADE)
category = models.ForeignKey(ProductCategory, on_delete=models.CASCADE)
description = models.TextField()
old_price = models.FloatField(null=True, blank=True)
price = models.FloatField(null=True)
input_date = models.DateTimeField(auto_now=False, auto_now_add=True)
update_date = models.DateTimeField(auto_now=True, auto_now_add=False)
def __str__(self):
return self.name
class Image(models.Model):
product_name = models.ForeignKey(Products, related_name='pro_images', on_delete=models.CASCADE)
image = models.ImageField(upload_to='media/product_img/', null=True, blank=True)
def __str__(self):
return self.product_name.name + 'image'
`
我的终端的下图请检查
python manage.py migrate product
使用特定模型名称迁移后,它对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.