Let these models:
class Category(models.Model):
name = models.CharField(max_length=20)
class Word(models.Model):
name = models.CharField(max_length=200)
categories = models.ManyToManyField(Category, null=True, blank=True)
And this view:
def main_page(request):
words = Word.objects.all()
return render(request, "main_page.html", {'words': words})
How can I filter words by categories passing a category as argument in a template?
You can just use the reverse relation: