У меня есть модели Offer
, Wood
, SliceTec
и JointTec
.И Wood
связано с SliceTec
и JointTec
полем M2M.В админке Django я могу выбрать несколько опций для SliceTec и JointTec при добавлении новой записи Wood.Нет проблем.Когда дело доходит до предложения, мне нужно показать опции из выбранных Дерева записей woodSlice данных, а также woodJoint данных.
Например,
Данные SliceTec: ломтик A, ломтик B, ломтик C
Данные JointTec: шарнир A, шарнир B, шарнир C
Данные древесины: древесина A, (ломтик A, ломтик C), (Jointt B, Jointt C)
При Offer
мне нужно показать Слайс A и Слайс B , когда Дерево A выбран.
class Offer(models.Model):
name = models.CharField(max_length=200, verbose_name='Adınız Soyadınız')
phone = models.BigIntegerField(verbose_name='Telefon Numaranız')
email = models.EmailField(verbose_name='E-mail Adresiniz')
date = models.DateTimeField(verbose_name='Teklif Tarihi')
frontWood = models.ForeignKey('Wood', on_delete=models.PROTECT)
frontSlice = models.CharField(max_length=200)
frontJoint = models.CharField(max_length=200)
frontSupport = models.ForeignKey('Support', on_delete=models.PROTECT)
frontThick = models.CharField(max_length=200)
frontDimen = models.CharField(max_length=200)
frontFlow = models.ForeignKey('Flow', on_delete=models.PROTECT)
frontGlue = models.ForeignKey('Glue', on_delete=models.PROTECT)
class Meta:
verbose_name = 'Teklif Talebi'
verbose_name_plural = 'Teklif Talepleri'
def __str__(self):
return self.name
class Wood(models.Model):
woodName = models.CharField(max_length=200, verbose_name='Ahşap Adı')
woodCode = models.CharField(max_length=50, verbose_name='Stok Kodu', blank=True, null=True)
woodSlice = models.ManyToManyField('SliceTec', verbose_name='Uygun Kesim Teknikleri')
woodJoint = models.ManyToManyField('JointTec', verbose_name='Uygun Ekleme Teknikleri')
woodImage = models.ImageField(verbose_name='Görsel', blank=True, null=True)
woodPrice = models.PositiveIntegerField(verbose_name='Fiyat Düzeyi', blank=True, null=True)
woodDesc = models.TextField(verbose_name='Açıklama', blank=True, null=True)
class Meta:
verbose_name = 'Ahşap Türü'
verbose_name_plural = 'Ahşap Türleri'
def __str__(self):
return self.woodName
class SliceTec(models.Model):
sliceName = models.CharField(max_length=200, verbose_name='Kesim Tekniği Adı')
sliceImage = models.ImageField(verbose_name='Görsel', blank=True, null=True)
sliceDesc = models.TextField(verbose_name='Açıklama', blank=True, null=True)
class Meta:
verbose_name = 'Kesim Tekniği'
verbose_name_plural = 'Kesim Teknikleri'
def __str__(self):
return self.sliceName
class JointTec(models.Model):
jointName = models.CharField(max_length=200, verbose_name='Ekleme Tekniği Adı')
jointImage = models.ImageField(verbose_name='Görsel', blank=True, null=True)
jointDesc = models.TextField(verbose_name='Açıklama', blank=True, null=True)
class Meta:
verbose_name = 'Ekleme Tekniği'
verbose_name_plural = 'Ekleme Teknikleri'
def __str__(self):
return self.jointName