Change date format in month pagination
This commit is contained in:
parent
2ba21fbd10
commit
f8c0f9dced
2 changed files with 7 additions and 5 deletions
|
@ -11,11 +11,11 @@
|
||||||
<p class="pagination">{% year_url month %}</p>
|
<p class="pagination">{% year_url month %}</p>
|
||||||
<p class="pagination n3">
|
<p class="pagination n3">
|
||||||
{% if previous_month %}
|
{% if previous_month %}
|
||||||
{% month_url previous_month %}
|
{% month_url previous_month fmt="F Y" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% month_url month cls="cur" %}
|
{% month_url month cls="cur" fmt="F Y" %}
|
||||||
{% if next_month %}
|
{% if next_month %}
|
||||||
{% month_url next_month %}
|
{% month_url next_month fmt="F Y" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -11,13 +11,15 @@ register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
def month_url(context, month, cls=""):
|
def month_url(context, month, cls="", fmt="Y-m"):
|
||||||
url_name, url_params = ac_url(
|
url_name, url_params = ac_url(
|
||||||
"transaction_month", {"year": month.year, "month": month.month}, context
|
"transaction_month", {"year": month.year, "month": month.month}, context
|
||||||
)
|
)
|
||||||
|
|
||||||
url = reverse(url_name, kwargs=url_params)
|
url = reverse(url_name, kwargs=url_params)
|
||||||
return mark_safe(f"""<a class="{cls}" href="{url}">{ date(month, "Y-m") }</a>""")
|
return mark_safe(
|
||||||
|
f"""<a class="{cls}" href="{url}">{date(month, fmt).capitalize()}</a>"""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
|
|
Loading…
Reference in a new issue