Django模型迁移两个表

2024-04-26 04:02:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个评论网站,写在Django,。。你知道吗

如何迁移模型以获取审阅数据-

我有一个product类和一个vendor类,最后还有一个review类,其中包含对产品和供应商的评审:

class Product(models.Model):
    ....

class Vendor(models.Model):
    ....

class Review(models.Model):
    slug = models.SlugField(max_length=255, unique=True)
    vendor = models.ForeignKey(Vendor)
    user = models.ForeignKey(User, blank=True, null=True)
    product = models.ForeignKey(Product, blank=True, null=True)
    images = models.ManyToManyField(ReviewImage, blank=True, null=True)
    headline = models.CharField(max_length=100)
    review = models.TextField(blank=True, null=True)
    rating = models.IntegerField()
    active = models.BooleanField(default=1)
    created = models.DateTimeField(auto_now_add=True)
    changed = models.DateTimeField(auto_now=True)

当我选择一个产品或供应商,我需要从审查类平均评级。。。我怎么能这么做?你知道吗


Tags: truemodel产品modelsproductnull供应商review

热门问题