Skip to content

Commit d46885f

Browse files
committed
change home view and template to listview
1 parent 9d7ae8e commit d46885f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

config/blog/templates/blog/home.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33
{% block title %}Home | {% endblock %}
44

55
{% block content %}
6-
<h1>Welcome to home page</h1>
6+
<div class="row">
7+
<div class="col-md-6 col-12 mx-md-auto mx-3 mt-5 md-5">
8+
<h1 class="fw-bolder">shahriaarrr Blog</h1>
9+
<h5 class="text-muted">Write about everything that i liked</h5>
10+
</div>
11+
</div>
712
{% endblock %}

config/blog/views.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
from django.shortcuts import render
22
from django.views import View
3+
from django.views.generic import ListView
4+
5+
from .models import Article
36
# Create your views here.
47

5-
class Index(View):
6-
def get(self, request):
7-
return render(request, 'blog/home.html')
8+
class Index(ListView):
9+
model = Article
10+
queryset = Article.objects.all().order_by("-date")
11+
template_name = 'blog/home.html'
812

913

1014
class About(View):

0 commit comments

Comments
 (0)