Skip to content

Commit 09b8e7c

Browse files
committed
Updated
1 parent 36980d9 commit 09b8e7c

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

boards/url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django.urls import path
22
from . import views
33
urlpatterns = [
4-
path('',views.home,name='home'),
4+
path('',views.BoardListView.as_view(),name='home'),
55
path('about/',views.about,name='about'),
66
path('boards/<int:board_id>/',views.board_topics,name='board_topics'),
77
path('boards/<int:board_id>/new/',views.new_topic,name='new_topic'),

boards/views.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@
66
from .forms import NewTopicForm, PostForm
77
from django.contrib.auth.decorators import login_required
88
from django.db.models import Count
9-
from django.views.generic import UpdateView
9+
from django.views.generic import UpdateView, ListView
1010
from django.utils import timezone
1111
from django.utils.decorators import method_decorator
1212
# Create your views here.
1313

14-
def home(request):
14+
# def home(request):
15+
#
16+
# boards = Board.objects.all()
17+
#
18+
# return render(request,'home.html',{'boards':boards})
1519

16-
boards = Board.objects.all()
17-
18-
return render(request,'home.html',{'boards':boards})
20+
class BoardListView(ListView):
21+
model = Board
22+
context_object_name = 'boards'
23+
template_name = 'home.html'
1924

2025

2126
def board_topics(request,board_id):

0 commit comments

Comments
 (0)