<div>
<h1><a href="">Django Girls Blog</a></h1>
</div>
-<div>
- <p>published: 14.06.2014, 12:14</p>
- <h2><a href="">My first post</a></h2>
- <p>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.</p>
-</div>
-<div>
- <p>published: 14.06.2014, 12:14</p>
- <h2><a href="">My second post</a></h2>
- <p>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.</p>
-</div>
+
+{% for post in posts %}
+ <div>
+ <p>Published: {{ post.published_date }}</p>
+ <h1><a href="">{{ post.title }}</a></h1>
+ <p>{{ post.text | linebreaksbr }}</p>
+ </div>
+{% endfor %}
</body>
</html>
\ No newline at end of file
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})