class Blog(models.Model):
name = models.CharField()
def get_posts_belonging_to_this_blog_instance(self):
return Post.objects.filter(blog__exact=self.id)
class Category(models.Model):
name = models.CharField()
def get_posts_with_this_category(self):
return Post.objects.filter(category__exact=self.id)
class Post(models.Model):
blog = models.ForeignKey(Blog)
category = models.ForeignKey(Category)
text = models.TextField()
Best way to explain it with code, is there a more Django approach to doing this?