Skip to content

Commit c57168b

Browse files
committed
Add custom template tags and filters
1 parent 1e41544 commit c57168b

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

mysite/templates/base.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% load static %}
2+
{% load blog_tags %}
23
<!DOCTYPE html>
34
<html>
45
<head>
@@ -12,7 +13,18 @@
1213
</div>
1314
<div id="sidebar">
1415
<h2>My blog</h2>
15-
<p>This is my blog.</p>
16+
<p>This is my blog. I've written {% total_posts %} posts so far.</p>
17+
<h3>Latest posts</h3>
18+
{% show_latest_posts 3 %}
19+
<h3>Most commented posts</h3>
20+
{% get_most_commented_posts as most_commented_posts %}
21+
<ul>
22+
{% for post in most_commented_posts %}
23+
<li>
24+
<a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
25+
</li>
26+
{% endfor %}
27+
</ul>
1628
</div>
1729
</body>
1830
</html>

poetry.lock

Lines changed: 58 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ python = "^3.7"
99
django = "^3.1.3"
1010
psycopg2-binary = "^2.8.6"
1111
django_taggit = "^1.3.0"
12+
markdown = "^3.3.3"
1213

1314
[tool.poetry.dev-dependencies]
1415

0 commit comments

Comments
 (0)