Simple index page
This commit is contained in:
10
videodinges/templates/index.html.j2
Normal file
10
videodinges/templates/index.html.j2
Normal 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>
|
||||
@@ -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)
|
||||
]
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user