# articleapp\views.py
# ...
class ArticleListView(ListView):
model = Article
context_object_name = 'article_list'
template_name = 'articleapp/list.html'
paginate_by = 25
# articleapp\urls.py
# ...
urlpatterns = [
path('list/', ArticleListView.as_view(), name='list'),
path('create/', ArticleCreateView.as_view(), name='create'),
path('detail/<int:pk>', ArticleDetailView.as_view(), name='detail'),
path('update/<int:pk>', ArticleUpdateView.as_view(), name='update'),
path('delete/<int:pk>', ArticleDeleteView.as_view(), name='delete'),
]
<!-- header.html -->
<div class="pragmatic_header">
<div>
<h1 class="pragmatic_logo">Pragmatic</h1>
</div>
<div>
<a href="{% url 'articleapp:list' %}">
<span>Articles</span>
</a>
<span>nav</span>
{% if not user.is_authenticated %}
<a href="{% url 'accountapp:login' %}?next={{ request.path }}">
<span>login</span>
</a>
<a href="{% url 'accountapp:create' %}">
<span>SignUp</span>
</a>
{% else %}
<a href="{% url 'accountapp:logout' %}?next{{ request.path }}">
<span>logout</span>
</a>
<a href="{% url 'accountapp:detail' pk=user.pk %}">
<span> MyPAge</span>
</a>
{% endif %}
</div>
</div>
<!-- articleapp\list.html -->
{% extends 'base.html' %}
{% load static %}
{% block content %}
<style>
.container div {
width: 250px;
background-color: antiquewhite;
display: flex;
justify-content: center;
align-items: center;
border-radius: 1rem;
}
.container img {
width: 100%;
border-radius: 1rem;
}
</style>
{% if article_list %}
<div class="container">
{% for article in article_list %}
<a href="{% url 'articleapp:detail' pk=article.pk %}">
{% include 'articleapp/snippets/card.html' with article=article %}
</a>
{% endfor %}
</div>
<script src="{% static 'js/magic-grid.js' %}"></script>
{% else %}
<div style="text-align:center;">
<h1>No Articles YET!</h1>
</div>
{% endif %}
<div style="text-align:center;">
<a href="{% url 'articleapp:create' %}" class="btn btn-dark rounded-pill col-3 mt-3 mb-3">
Create Article
</a>
</div>
{% endblock %}
<!-- articleapp\card.html -->
<div>
<img src="{{ article.image.url }}" alt="">
</div>