0
我正在按照本教程(http://lightbird.net/dbe/cal1.html)構建日曆應用程序,但無法使模板正常工作。無法讓模板在Django中工作
我在project/templates
中創建了一個名爲cal
的目錄,並在那裏複製了base.html
。然後我伸出模板有以下幾點:
{% extends "cal/base.html" %}
<!-- ... -->
<a href="{% url cal.views.main year|add:'-3' %}"><< Prev</a>
<a href="{% url cal.views.main year|add:'3' %}">Next >></a>
{% for year, months in years %}
<div class="clear"></div>
<h4>{{ year }}</h4>
{% for month in months %}
<div class=
{% if month.current %}"current"{% endif %}
{% if not month.current %}"month"{% endif %} >
{% if month.entry %}<b>{% endif %}
<a href="{% url cal.views.month year month.n %}">{{ month.name }}</a>
{% if month.entry %}</b>{% endif %}
</div>
{% if month.n == 6 %}<br />{% endif %}
{% endfor %}
{% endfor %}
在我project/urls.py
我有以下配置:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^cal/', include('cal.urls')),
url(r'^admin/', include(admin.site.urls)),
)
在cal/urls.py
我有以下配置:
from django.conf.urls import patterns, include, url
from cal.views import main
urlpatterns = patterns('cal.views',
(r'^(\d+)/$', main),
(r'', main),
)
我我不知道我出錯的地方。現在所有這一切都顯示出來,當我運行的應用程序是一個空白屏幕上左上角有帶我到後臺管理頁面了「家」按鈕。如果有人能夠指引我正確的方向,將不勝感激!