File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from django .urls import path
22from . import views
33urlpatterns = [
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' ),
Original file line number Diff line number Diff line change 66from .forms import NewTopicForm , PostForm
77from django .contrib .auth .decorators import login_required
88from django .db .models import Count
9- from django .views .generic import UpdateView
9+ from django .views .generic import UpdateView , ListView
1010from django .utils import timezone
1111from 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
2126def board_topics (request ,board_id ):
You can’t perform that action at this time.
0 commit comments