0
votes

I add the category section in the model and the slugify function loads posts with one-word category but it's not loading the posts with multiple words

View Function:

def CategoryView(request, cats):
    category_posts = Item.objects.filter(item_category__slug=cats.replace('-', ''))
    return render(request, 'waqart/categories.html', {'cats':cats, 'category_posts':category_posts })

Model:

class Categories(models.Model):
    name = models.CharField(max_length=200)
    summary = models.CharField(max_length=200)
    slug = models.CharField(max_length=200)

    class Meta:
        verbose_name_plural = 'Categories'

    def __str__(self):
        

        return self.name