From fc7af4fa7808fc54c7f5d25bf5abfd58bd6c6ba5 Mon Sep 17 00:00:00 2001 From: Bastiaan Welmers Date: Tue, 5 May 2020 13:50:15 +0200 Subject: [PATCH] Simple index page --- videodinges/templates/index.html.j2 | 10 ++++++++++ videodinges/urls.py | 1 + videodinges/views.py | 4 ++++ 3 files changed, 15 insertions(+) create mode 100644 videodinges/templates/index.html.j2 diff --git a/videodinges/templates/index.html.j2 b/videodinges/templates/index.html.j2 new file mode 100644 index 0000000..df10823 --- /dev/null +++ b/videodinges/templates/index.html.j2 @@ -0,0 +1,10 @@ + + +

Video's

+ + + \ No newline at end of file diff --git a/videodinges/urls.py b/videodinges/urls.py index 16fac84..9ae9eee 100644 --- a/videodinges/urls.py +++ b/videodinges/urls.py @@ -22,6 +22,7 @@ from . import testviews, views urlpatterns = [ url(r'^admin/', admin.site.urls), + url(r'^$', views.index), url(r'^(?P[\w-]+).html', views.video) ] diff --git a/videodinges/views.py b/videodinges/views.py index 43cffb2..39bad45 100644 --- a/videodinges/views.py +++ b/videodinges/views.py @@ -53,6 +53,10 @@ def video(request: HttpRequest, slug: str) -> HttpResponse: return render(request, 'video.html.j2', template_data, using='jinja2') +def index(request: HttpRequest) -> HttpResponse: + videos = models.Video.objects.order_by('-created_at').all() + return render(request, 'index.html.j2', dict(videos=videos), using='jinja2') + def _get_dict_from_models_with_fields(model, *fields: str) -> Dict[str, Any]: ret = {} for field in fields: