1
这是产品数据库的模型。我发现,在模板上渲染产品时,产品与不同的测量结果相同。有没有办法将这些产品分组在一起,以便项目不会重复。如何对模板中的django模型字段进行排序/过滤
class Product(models.Model):
product_code = models.CharField(max_length=60, null=True, blank=True)
type = models.CharField(max_length=120, null=True, blank=True)
product = models.CharField(max_length=120, null=True, blank=True)
standard = models.CharField(max_length=120, null=True, blank=True)
measurement = models.CharField(max_length=120, null=True, blank=True)
brand = models.CharField(max_length=120, null=True, blank=True)
photo = models.ImageField(upload_to='media', null=True, blank=True)
price = models.DecimalField(max_digits=100, decimal_places=3, null=True, blank=True)
class Meta:
verbose_name_plural = "Product"
ordering = ["id"]
def get_absolute_url(self):
return reverse('product')
def __unicode__(self):
return u'%s %s %s %s %s %s %s' % (self.id, self.product_code, self.type,
self.product, self.standard,
self.measurement, self.brand, self.photo, self.price)
嘿,它绝对超过3-5。我如何处理现场数据?另外每个产品都有与之相关的唯一产品代码。 – vvdect
好的,所以你说的是他们真的是独特的产品,但他们是相似的,主要的区别是测量。产品代码是否像SKU一样?一些数据的例子可能真的有助于这个...尤其是两种相似的产品,如果您不想同时列出不同的测量结果。 – Walter
嘿,我很难解释这一点。这里是excel产品列表的屏幕截图。我希望这有助于: [Excel截图](https://drive.google.com/file/d/0B4d4RhPuJVGMN3RPVXphbnBOWjA/edit?usp=sharing) – vvdect