How do I return the number of books published in the template?
I have this
# models.py
class PublishedManager(models.Manager):
def published(self):
return self.filter(published=True)
class Book(models.Model):
name = models.CharField('nome', max_length=50)
authors = models.ManyToManyField('Author', verbose_name='autores')
published = models.BooleanField('publicado', default=True)
# add our custom model manager
objects = PublishedManager()
and
#views.py
class BookList(ListView):
model = Book
context_object_name = 'books'
paginate_by = 10
I tried this
# template.html
<p>Livros publicados: {{ books.published.count }}</p>
But it was not.