Use a custom ISO date format to please HTML <time>

This commit is contained in:
Gabriel Augendre 2020-08-25 23:11:15 +02:00
parent 67105db5a9
commit cfc427b603
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
4 changed files with 8 additions and 3 deletions

View file

@ -7,3 +7,7 @@ def pages(request):
def drafts_count(request):
return {"drafts_count": Article.with_pages.filter(status=Article.DRAFT).count()}
def date_format(request):
return {"CUSTOM_ISO": "Y-m-d\TH:i:sO"}

View file

@ -5,7 +5,7 @@
<p class="metadata">
<a class="permalink" title="Permalink" href="#{{ comment.id }}">🔗</a>
<span class="username">{{ comment.username }}</span> |
<time datetime="{{ comment.created_at|date:'c' }}">
<time datetime="{{ comment.created_at|date:CUSTOM_ISO }}">
{{ comment.created_at|date:"DATETIME_FORMAT" }}
</time>
{% include "articles/admin_link_snippet.html" with article=comment %}

View file

@ -1,9 +1,9 @@
{% load i18n %}
<p class="date">
{% if article.published_at %}
<time datetime="{{ article.published_at|date:'c' }}">{{ article.published_at|date }}</time>
<time datetime="{{ article.published_at|date:CUSTOM_ISO }}">{{ article.published_at|date }}</time>
{% else %}
<time datetime="{{ article.updated_at|date:'c' }}">{{ article.updated_at|date }}</time>
<time datetime="{{ article.updated_at|date:CUSTOM_ISO }}">{{ article.updated_at|date }}</time>
{% endif %}
{% include "articles/admin_link_snippet.html" %}
</p>

View file

@ -96,6 +96,7 @@ TEMPLATES = [
"django.contrib.messages.context_processors.messages",
"articles.context_processors.pages",
"articles.context_processors.drafts_count",
"articles.context_processors.date_format",
],
},
},