From e8c332fce41cd02b7c46b342cbdc7b4b514338f0 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Mon, 2 Oct 2023 11:04:48 +0200 Subject: [PATCH] add date to card view --- gawa/blog/templates/blog/featured.html | 7 +++++++ gawa/start/templatetags/helper_tags.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gawa/blog/templates/blog/featured.html b/gawa/blog/templates/blog/featured.html index 28cfd8b..4f025e5 100644 --- a/gawa/blog/templates/blog/featured.html +++ b/gawa/blog/templates/blog/featured.html @@ -1,4 +1,5 @@ {% load i18n %} +{% load helper_tags %} {% get_current_language as LANGUAGE_CODE %}

{% trans "Featured" %}

@@ -45,6 +46,12 @@ {% endfor %}
+
+
  • + {% format_time post.date "%F" as date %} + {% trans "published" %}: {{ date }} +
  • +
    {% endfor %} diff --git a/gawa/start/templatetags/helper_tags.py b/gawa/start/templatetags/helper_tags.py index fe8780c..17d8d8e 100644 --- a/gawa/start/templatetags/helper_tags.py +++ b/gawa/start/templatetags/helper_tags.py @@ -11,8 +11,8 @@ logger = logging.getLogger(__name__) register = Library() @register.simple_tag -def format_time(timestamp: datetime) -> str: - return timestamp.strftime("%F %H:%M:%S") +def format_time(timestamp: datetime, format: str = "%F %H:%M:%S") -> str: + return timestamp.strftime(format) @register.simple_tag(takes_context=True) def change_lang(context, lang="de", *args, **kwargs):