Change display date format
This commit is contained in:
parent
3ff0c0292f
commit
c9c378e2d6
4 changed files with 8 additions and 11 deletions
|
@ -23,7 +23,7 @@ def drafts_count(request):
|
|||
def date_format(request):
|
||||
if request.path in IGNORED_PATHS:
|
||||
return {}
|
||||
return {"CUSTOM_ISO": r"Y-m-d\TH:i:sO"}
|
||||
return {"CUSTOM_ISO": r"Y-m-d\TH:i:sO", "ISO_DATE": "Y-m-d"}
|
||||
|
||||
|
||||
def git_version(request):
|
||||
|
|
|
@ -9,11 +9,7 @@
|
|||
<ul>
|
||||
{% for article in articles %}
|
||||
<li>
|
||||
{% if article.published_at %}
|
||||
<time datetime="{{ article.published_at|date:CUSTOM_ISO }}">{{ article.published_at|date }}</time>
|
||||
{% else %}
|
||||
<time datetime="{{ article.updated_at|date:CUSTOM_ISO }}">{{ article.updated_at|date }}</time>
|
||||
{% endif %}
|
||||
{% include "articles/datetime_snippet.html" %}
|
||||
: <a href="{% url 'article-detail' slug=article.slug %}">{{ article.title }}</a>
|
||||
</li>
|
||||
{% empty %}
|
||||
|
|
5
articles/templates/articles/datetime_snippet.html
Normal file
5
articles/templates/articles/datetime_snippet.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% if article.published_at %}
|
||||
<time datetime="{{ article.published_at|date:CUSTOM_ISO }}">{{ article.published_at|date:ISO_DATE }}</time>
|
||||
{% else %}
|
||||
<time datetime="{{ article.updated_at|date:CUSTOM_ISO }}">{{ article.updated_at|date:ISO_DATE }}</time>
|
||||
{% endif %}
|
|
@ -1,9 +1,5 @@
|
|||
{% load i18n %}
|
||||
<p class="metadata">
|
||||
{% if article.published_at %}
|
||||
<time datetime="{{ article.published_at|date:CUSTOM_ISO }}">{{ article.published_at|date }}</time>
|
||||
{% else %}
|
||||
<time datetime="{{ article.updated_at|date:CUSTOM_ISO }}">{{ article.updated_at|date }}</time>
|
||||
{% endif %}
|
||||
{% include "articles/datetime_snippet.html" %}
|
||||
{% include "articles/admin_link_snippet.html" %}
|
||||
</p>
|
||||
|
|
Reference in a new issue