Only display published articles
This commit is contained in:
parent
02d7169314
commit
0c1d0a0b29
2 changed files with 8 additions and 0 deletions
|
@ -8,5 +8,7 @@
|
||||||
<p>{{ article.get_abstract|safe }}</p>
|
<p>{{ article.get_abstract|safe }}</p>
|
||||||
<p><a href="{% url 'article-detail' pk=article.pk %}">Read more</a></p>
|
<p><a href="{% url 'article-detail' pk=article.pk %}">Read more</a></p>
|
||||||
</article>
|
</article>
|
||||||
|
{% empty %}
|
||||||
|
<p>No article here. Come back later 🙂</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -8,7 +8,13 @@ class ArticlesListView(generic.ListView):
|
||||||
paginate_by = 15
|
paginate_by = 15
|
||||||
context_object_name = "articles"
|
context_object_name = "articles"
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return super().get_queryset().filter(status=Article.PUBLISHED)
|
||||||
|
|
||||||
|
|
||||||
class ArticleDetailView(generic.DetailView):
|
class ArticleDetailView(generic.DetailView):
|
||||||
model = Article
|
model = Article
|
||||||
context_object_name = "article"
|
context_object_name = "article"
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return super().get_queryset().filter(status=Article.PUBLISHED)
|
||||||
|
|
Reference in a new issue