Simple index page

This commit is contained in:
2020-05-05 13:50:15 +02:00
parent be747db93f
commit fc7af4fa78
3 changed files with 15 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<html>
<body>
<h1>Video's</h1>
<ul>
{% for video in videos %}
<li><a href="{{ video.slug }}.html">{{ video.title }}</a></li>
{% endfor %}
</ul>
</body>
</html>

View File

@@ -22,6 +22,7 @@ from . import testviews, views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', views.index),
url(r'^(?P<slug>[\w-]+).html', views.video)
]

View File

@@ -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: