From: Neil Smith Date: Wed, 5 Oct 2016 09:40:55 +0000 (+0100) Subject: Added template to a view X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=520a95911abd002abf604a7479170cc900359cbb;p=django-girls.git Added template to a view --- diff --git a/blog/templates/blog/post_list.html b/blog/templates/blog/post_list.html index aa9d1d5..b5f3995 100644 --- a/blog/templates/blog/post_list.html +++ b/blog/templates/blog/post_list.html @@ -8,16 +8,14 @@

Django Girls Blog

-
-

published: 14.06.2014, 12:14

-

My first post

-

Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut rmentum mass a justo sit amet risus.

-
-
-

published: 14.06.2014, 12:14

-

My second post

-

Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut f.

-
+ +{% for post in posts %} +
+

Published: {{ post.published_date }}

+

{{ post.title }}

+

{{ post.text | linebreaksbr }}

+
+{% endfor %} \ No newline at end of file diff --git a/blog/views.py b/blog/views.py index 299ca35..9a8aa8b 100644 --- a/blog/views.py +++ b/blog/views.py @@ -1,4 +1,7 @@ from django.shortcuts import render +from django.utils import timezone +from .models import Post def post_list(request): - return render(request, 'blog/post_list.html', {}) + posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date') + return render(request, 'blog/post_list.html', {'posts': posts})