Trying to get the total count of objects with a bool value of true to display on the template Here's what I have so far

Trying to get the total count of objects with a bool value of true or false to display on the template

Here’s what I have so far

class Issue(models.Model):
    MARK_AS = ((True, 'Open'), (False, 'Closed'))
    title = models.CharField(max_length=100)
    content = models.TextField()
    date_posted = models.DateTimeField(
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    assignee = models.ForeignKey(Profile, on_delete=models.SET_NULL, null=True, blank=True)
    mark_as = models.BooleanField(choices=MARK_AS, default=True)

class IssueListView(ListView):
    model = Issue
    template_name = 'issues/home.html'
    context_object_name = 'issues'
    ordering = ['-date_posted']
    paginate_by = 5
    def total():
        open_issues = Issue.objects.filter(mark_as=True).count()
        closed_issues = Issue.objects.filter(mark_as=False).count()
        context = { 
                'open_issues': open_issues,
                'closed_issues': closed_issues}
        return context


<ul class="topics__list">
            <a href="" class="active">All <span>{{ page_obj.paginator.count }}</span></a>
            <a href="">Open<span>{{issues.open_issues}}</span></a>
            <a href="">Closed<span>{{issues.closed_issues}}</span></a>


Screenshot 2022-04-17 193334

It doesn’t work, where do i go from here?

You should become more familiar with how the Class-Based views work, and how you integrate with them. In addition to the docs, I recommend both the Classy ClassBased View site along with the CBV diagrams page to understand how they work. (Your “total” function isn’t doing anything - it not even going to be called.)

Briefly, you’ll be overriding the get_context_data method of the view class to add this data to the context to be rendered.