The SSH host key has changed on 8 April, 2022 to this one: SHA256:573uTBSeh74kvOo0HJXi5ijdzRm8me27suzNEDlGyrQ

Add get_post_relative_link template tag to generate relative links to blog posts

master
Gergely Polonkai 8 years ago
parent c383c99075
commit a7c649d5c1
  1. 7
      blog/templatetags/blog_link.py

@ -1,8 +1,15 @@
from django import template
from django.core.urlresolvers import reverse
from django.conf import settings
import pytz
register = template.Library()
@register.simple_tag
def get_post_relative_link(post):
post_date = post.created_at.astimezone(pytz.timezone(settings.TIME_ZONE))
return reverse('blog:read', args=(post_date.year, post_date.month, post_date.day, post.slug))
@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)))

Loading…
Cancel
Save