From 34d1cefe702ee01495322e7abb495e6bdfdf8830 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sat, 21 Jun 2014 22:08:18 +0200 Subject: [PATCH] Add get_post_link template tag to create post backlinks --- blog/templatetags/blog_link.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 blog/templatetags/blog_link.py diff --git a/blog/templatetags/blog_link.py b/blog/templatetags/blog_link.py new file mode 100644 index 0000000..df3bc13 --- /dev/null +++ b/blog/templatetags/blog_link.py @@ -0,0 +1,8 @@ +from django import template +from django.core.urlresolvers import reverse + +register = template.Library() + +@register.simple_tag(takes_context = True) +def get_post_link(context, post): + return context['request'].build_absolute_uri(reverse('blog:read', args=(post.created_at.year, post.created_at.month, post.created_at.day, post.slug)))