Commit 2a9d1e34 authored by Борис Ким's avatar Борис Ким

Добавил вью для отображения курсов

parent ea6730bc
...@@ -19,5 +19,5 @@ from webapp.views import courses_views as webapp_views ...@@ -19,5 +19,5 @@ from webapp.views import courses_views as webapp_views
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('', webapp_views.my_view, name='main') path('', webapp_views.CoursesListView.as_view(), name='courses_list')
] ]
{% block title %} List {% endblock %}
{% block content %}
{% for course in courses %}
<div class="card">
<div class="card-header">
Featured
</div>
<div class="card-body">
<h5 class="card-title"> {{course.title}} </h5>
<p class="card-text"> {{course.description}} </p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
{% endfor %}
{% endblock %}
\ No newline at end of file
from typing import List
from django.shortcuts import render from django.shortcuts import render
from django.views.generic import ListView, CreateView, DeleteView, UpdateView, DetailView
from webapp.models import Course
def my_view(request):
return render(request, 'base.html') class CoursesListView(ListView):
\ No newline at end of file model = Course
context_object_name = 'courses'
template_name = 'courses/courses_list.html'
paginate_by = 9
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment