Code

#19471 closed Uncategorized (worksforme)

base_site.html should actually be base.html at the end of tutorial 2

Reported by: brandon@… Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords: tutorial
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In the documentation for tutorial 2 1.4, https://docs.djangoproject.com/en/1.4/intro/tutorial02/, I believe references to base_site.html need to be adjusted to base.html.

Now copy the template admin/base_site.html from within the default Django admin template directory in the source code of Django itself (django/contrib/admin/templates) into an admin subdirectory of whichever directory you're using in TEMPLATE_DIRS. For example, if your TEMPLATE_DIRS includes '/home/my_username/mytemplates', as above, then copy django/contrib/admin/templates/admin/base_site.html to /home/my_username/mytemplates/admin/base_site.html. Don't forget that admin subdirectory.

Then, just edit the file and replace the generic Django text with your own site's name as you see fit.

This template file contains lots of text like {% block branding %} and {{ title }}. The {% and {{ tags are part of Django's template language. When Django renders admin/base_site.html, this template language will be evaluated to produce the final HTML page. Don't worry if you can't make any sense of the template right now -- we'll delve into Django's templating language in Tutorial 3.

Note that any of Django's default admin templates can be overridden. To override a template, just do the same thing you did with base_site.html -- copy it from the default directory into your custom directory, and make changes.

Astute readers will ask: But if TEMPLATE_DIRS was empty by default, how was Django finding the default admin templates? The answer is that, by default, Django automatically looks for a templates/ subdirectory within each app package, for use as a fallback. See the template loader documentation for full information.

In my install of Django 1.4.3, the file was base.html, not base_site.html.

base_site.html includes the following:

{% extends "admin/base.html" %}
{% load i18n %}

{% block title %}{{ title }} | {% trans 'Django site admin' %}{% endblock %}

{% block branding %}
<h1 id="site-name">{% trans 'Django administration' %}</h1>
{% endblock %}

{% block nav-global %}{% endblock %}

Which does not match the description provided in the documentation.

Attachments (0)

Change History (1)

comment:1 Changed 16 months ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

The reference to base_site.html is correct, that is the name of the file and it is included in Django 1.4.3:

kmtracey@ubuntu 05:38:52: ~
--> mkvirtualenv django143
New python executable in django143/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /home/kmtracey/.virtualenvs/django143/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/kmtracey/.virtualenvs/django143/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/kmtracey/.virtualenvs/django143/bin/preactivate
virtualenvwrapper.user_scripts creating /home/kmtracey/.virtualenvs/django143/bin/postactivate
virtualenvwrapper.user_scripts creating /home/kmtracey/.virtualenvs/django143/bin/get_env_details

(django143) kmtracey@ubuntu 05:39:04: ~
--> pip install django==1.4.3
Downloading/unpacking django==1.4.3
  Downloading Django-1.4.3.tar.gz (7.7MB): 7.7MB downloaded
  Running setup.py egg_info for package django
    
Installing collected packages: django
  Running setup.py install for django
    changing mode of build/scripts-2.7/django-admin.py from 664 to 775
    
    changing mode of /home/kmtracey/.virtualenvs/django143/bin/django-admin.py to 775
Successfully installed django
Cleaning up...

(django143) kmtracey@ubuntu 05:40:56: ~
--> cdsitepackages 

(django143) kmtracey@ubuntu 05:41:01: ~/.virtualenvs/django143/lib/python2.7/site-packages
--> cat django/contrib/admin/templates/admin/base_site.html 
{% extends "admin/base.html" %}
{% load i18n %}

{% block title %}{{ title }} | {% trans 'Django site admin' %}{% endblock %}

{% block branding %}
<h1 id="site-name">{% trans 'Django administration' %}</h1>
{% endblock %}

{% block nav-global %}{% endblock %}

(django143) kmtracey@ubuntu 05:41:16: ~/.virtualenvs/django143/lib/python2.7/site-packages
--> 

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.