Answer the question
In order to leave comments, you need to log in
Python/Django Product filter on website?
I'm learning django and I'm stuck on implementing filters on the product listing page.
Models:
class Products(models.Model):
date_create = models.DateTimeField(auto_now_add=True, verbose_name='Дата создания')
date_edite = models.DateTimeField(auto_now=True, verbose_name='Дата изменения')
category = TreeForeignKey('Category', on_delete=models.SET_NULL, null=True, blank=True, verbose_name="Категория", db_index=True)
nazvanie = models.CharField(max_length=350, verbose_name='Название', db_index=True)
kodtovara = models.CharField(max_length=50, verbose_name='Фирменный код', null=True, blank=True, db_index=True)
article = models.CharField(max_length=50, verbose_name='Артикул', null=True, blank=True, db_index=True)
slug = models.SlugField(blank=True)
class PropertiesProduct(models.Model):
nazvanie = models.CharField(max_length=500, verbose_name='Название', db_index=True)
slug_nazvanie = models.SlugField(blank=True)
znachenie = models.CharField(max_length=500, verbose_name='Значение', db_index=True)
slug_znachenie = models.SlugField(blank=True)
detail = models.BooleanField(null=True, blank=True, verbose_name='Использовать как свойство в описании товара', db_index=True, default=True)
filter = models.BooleanField(null=True, blank=True, verbose_name='Использовать для фильтра', db_index=True, default=True)
register = models.BooleanField(null=True, blank=True, verbose_name='Расширенные свойства', db_index=True, default=False)
tovary = models.ForeignKey('Products', on_delete=models.SET_NULL, null=True, verbose_name='Товар', db_index=True)
Answer the question
In order to leave comments, you need to log in
Read about EAV , look at implementations . Then read about faceted search and google its implementations. And then decide what is best suited specifically for your project and whether it is worth cutting your own solution or taking a ready-made one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question