テンプレートタグの追加

カレンダーを表示したいと思ってたらdjango snippetsにCalendar template-tagと言うものがあった。
こいつを使えば{% month_cal 2008 7 %}と記述するとカレンダーが表示されるらしい。
ということでやってみた。

$ cd diary/
$ ls
__init__.py   __init__.pyo  models.pyc  urls.py   views.py   views.pyo
__init__.pyc  models.py     models.pyo  urls.pyc  views.pyc
$ mkdir templatetags
$ cd templatetags/
$ touch __init__.py
$ cp ~/month_cal.py ./

month_cal.pyの中にクラス名・クラス変数名を適せん修正する。
templates/diary/month_cal.htmlを作成する。内容はmonth_cal.pyに書いてある。
表示したいテンプレートdiary_archive.htmlに以下を追記する。

{% load month_cal %}
{% month_cal 2008 7 %}

無事に表示された。

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy