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):
|
def date_format(request):
|
||||||
if request.path in IGNORED_PATHS:
|
if request.path in IGNORED_PATHS:
|
||||||
return {}
|
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):
|
def git_version(request):
|
||||||
|
|
|
@ -9,11 +9,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
{% for article in articles %}
|
{% for article in articles %}
|
||||||
<li>
|
<li>
|
||||||
{% if article.published_at %}
|
{% include "articles/datetime_snippet.html" %}
|
||||||
<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 %}
|
|
||||||
: <a href="{% url 'article-detail' slug=article.slug %}">{{ article.title }}</a>
|
: <a href="{% url 'article-detail' slug=article.slug %}">{{ article.title }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% empty %}
|
{% 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 %}
|
{% load i18n %}
|
||||||
<p class="metadata">
|
<p class="metadata">
|
||||||
{% if article.published_at %}
|
{% include "articles/datetime_snippet.html" %}
|
||||||
<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/admin_link_snippet.html" %}
|
{% include "articles/admin_link_snippet.html" %}
|
||||||
</p>
|
</p>
|
||||||
|
|
Reference in a new issue