Modified templates to display posts from database.
This commit is contained in:
@@ -22,5 +22,12 @@
|
|||||||
<h2><a href="">My second post</a></h2>
|
<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>
|
<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>
|
</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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from .models import Post
|
||||||
|
from django.utils import timezone
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
def post_list(request):
|
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})
|
||||||
Reference in New Issue
Block a user