i am a beginner in django mptt urls....thanks in advance
class Category(MPTTModel):
title = models.CharField(max_length =120)
parent = TreeForeignKey('self' , null = True , blank = True , verbose_name='parent category', related_name='categories')
def get_absolute_url(self):
return reverse('categories', kwargs={'path': self.get_path()})
def get_clothes(self):
return Product.objects.filter(category__in=self.get_descendants(include_self=True))
class Product(models.Model):
brand = ForeignKey('Brand', verbose_name='brands', related_name='brand' , default='')
category = TreeForeignKey('Category', verbose_name='categories', related_name='products' , default='')
i have categories like this
men > men clothing > tshirts
my template
{% for product in instance.get_clothes %}
{{ product.title }}
{% endfor %}
how can i filter based on brand and still show the result on the same template ?