Answer the question
In order to leave comments, you need to log in
How to display product features in django admin?
There is an electronics store on django. There is a model - Product, which stores information about the product. Each product has its own technical characteristics (processor - clock frequency, monitor - diagonal, hard disk - volume, etc.). At the moment, you have to fill in the fields "by hand" for each product: select a parameter (for example, a monitor), write its description on the right. We add one more parameter - and again the description. And so for each product.
How can I make it so that, for example, by going to the HP-530 product card, you can select the "laptops" group, save it - and a certain field template will be displayed (on the left is the parameter, on the right is its description)?
Thank you
Answer the question
In order to leave comments, you need to log in
class TechInfo(models.Model):
title = models.CharField(_(u'заголовок'), max_length=255)
def __unicode__(self):
return self.title
class Meta:
ordering = ('title',)
class ProductTechInfo(models.Model):
"""техническая информация для продуктов
"""
product = models.ForeignKey(Product, verbose_name=_(u"товар"), related_name="techinfo")
name = models.ForeignKey(TechInfo, verbose_name=_(u"имя"), related_name="name")
value = models.TextField(_(u'значение'), blank=True)
separator = models.BooleanField(_(u'заголовок?'), default=False)
position = models.SmallIntegerField(_(u'позиция'), default=999)
def __unicode__(self):
return u"%s" % (self.name)
class Meta:
ordering = ('position',)
verbose_name = _(u'техническая информация')
verbose_name_plural = _(u'техническая информация')
Maybe you need
https://docs.djangoproject.com/en/1.6/ref/contrib/...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question