add date to card view

This commit is contained in:
Christoph J. Scherr 2023-10-02 11:04:48 +02:00
parent 6f2267e18a
commit e8c332fce4
2 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,5 @@
{% load i18n %} {% load i18n %}
{% load helper_tags %}
{% get_current_language as LANGUAGE_CODE %} {% get_current_language as LANGUAGE_CODE %}
<div class="container-lg mt-5"> <div class="container-lg mt-5">
<h4 class="">{% trans "Featured" %}</h4> <h4 class="">{% trans "Featured" %}</h4>
@ -45,6 +46,12 @@
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
<div class="container p-1 text-center" style="border-top: solid">
<li class="list-group-item">
{% format_time post.date "%F" as date %}
{% trans "published" %}: {{ date }}
</li>
</div>
</a> </a>
</div> </div>
{% endfor %} {% endfor %}

View File

@ -11,8 +11,8 @@ logger = logging.getLogger(__name__)
register = Library() register = Library()
@register.simple_tag @register.simple_tag
def format_time(timestamp: datetime) -> str: def format_time(timestamp: datetime, format: str = "%F %H:%M:%S") -> str:
return timestamp.strftime("%F %H:%M:%S") return timestamp.strftime(format)
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)
def change_lang(context, lang="de", *args, **kwargs): def change_lang(context, lang="de", *args, **kwargs):