i'm attempting follow django tutorial, part 2, , getting stuck on last part templates. problem i'm experiencing i'm changing base_site.html , no changes being reflected in site. using python 3.4
per tutorial, created file-structure "templates" folder in same directory manage.py.
- tutorial
- tutorial
- polls
- templates
- admin
- base_site.html
- admin
- manage.py
then, modified templates 'dirs' [os.path.join(base_dir,'templates')]
settings.py:
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ... installed_apps = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'polls' ) middleware_classes = ( 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.auth.middleware.sessionauthenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', 'django.middleware.clickjacking.xframeoptionsmiddleware', 'django.middleware.security.securitymiddleware', ) root_urlconf = 'tutorial.urls' print(os.path.join(base_dir, 'templates')) templates = [ { 'backend': 'django.template.backends.django.djangotemplates', 'dirs': [os.path.join(base_dir, 'templates')], 'app_dirs': true, 'options': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] then, modified base_site.html read:
{% extends "admin/base.html" %} {% block title %}{{ title }} | {{ site_title|default:_('my admin title') {% endblock %} {% block branding %} <h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('my admin header') }}</a></h1> {% endblock %} {% block nav-global %}{% endblock %} finally, navigated website at:
http://localhost:8000/admin/ however, i'm still greeted title "site administration".
i checked directory looking @ (the print() line in settings.py), , directory looks correct:
/home/<user>/documents/djangoprojects/tutorial/templates i've checked out this thread , others, have not found helpful. believe i've followed tutorial tee, can of please me understand how i'm interpreting tutorial incorrectly? or documentation bug?
there nothing wrong doing, problem how template's default filter works.
this filter give value on right of |, if value of left of | not passed template.
since django admin application passing in value site_title, default filter not triggered.
if trying change title displayed, can set value of site_title customizing django admin (as move further in tutorial, learn more customizing admin, make link clearer).
if want see if setup correct, can change template following:
{% block title %} foo: {{ title }} | {{ site_title|default:_('my admin title') }} {% endblock %} then refresh admin site , watch title of page.
Comments
Post a Comment