Can't get templates to work in Django -
i'm following tutorial (http://lightbird.net/dbe/cal1.html) build calendar app, can't templates work correctly.
i made directory named cal
in project/templates
, copied base.html
there. extended template cal/main.html
following:
{% 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> {% year, months in years %} <div class="clear"></div> <h4>{{ year }}</h4> {% 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 %}
in project/urls.py
have following configuration:
from django.conf.urls import patterns, include, url django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^cal/', include('cal.urls')), url(r'^admin/', include(admin.site.urls)), )
in cal/urls.py
have following configuration:
from django.conf.urls import patterns, include, url cal.views import main urlpatterns = patterns('cal.views', (r'^(\d+)/$', main), (r'', main), )
i'm not sure went wrong. showing right when run app blank screen "home" button on top left corner takes me admin page. if point me in right direction, appreciated!
in base.html must have that:
{% block content %}{% endblock %}
and in main.html:
{% extends "cal/base.html" %} {% block content %} <a href="{% url cal.views.main year|add:'-3' %}"><< prev</a> <a href="{% url cal.views.main year|add:'3' %}">next >></a> {% year, months in years %} <div class="clear"></div> <h4>{{ year }}</h4> {% 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 %} {% endblock %}
Comments
Post a Comment