I have a Blog
model that looks like this:
class Blog(models.Model):
title = models.CharField(max_length=200)
content = models.TextField()
slug = models.SlugField(max_length=200, unique=True)
author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='blogs')
parent = models.CharField(max_length=50, choices=PARENT_TUTORIALS)
def get_absolute_url(self):
return reverse("blog_list", args=[str(self.parent), str(self.slug)])
I can succesfully display all the blogs on a table of contents via my table.html
template:
However, I want to show only those blogs that have the same Blog.parent
value as the current blog page. For example, the page example.com/biology/page1
, has biology
as a parent. When the user is on that page, the table of contents should show only the pages that have biology
as a parent.
Aucun commentaire:
Enregistrer un commentaire