--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
I did try this, and I tried again, but it still doesn't work.
Do I need to do something extra like quit the server, and restart again? By the way I did try this too.
Now, I am totally lost.
in settings.py
# this is the directory containing settings.py
PROJECT_DIR = os.path.realpath(os.path.dirname(__file__))
# if templates are not found here look in app_name/templates
TEMPLATE_DIRS = (os.path.join(PROJECT_DIR, 'templates/'),)
This makes my templates directory a sub-dir of the project dir and
inside that there are other sub-dirs one for each app and one for the admin.
I don't really need one for the admin because django knows where the
admin templates live inside the django tree.
However, there is one admin template I override so that I can
personalise the admin. That is called base_site.html. It is ...
PROJECT_DIR/templates/admin/base_site.html
It is the only admin template I change and it only contains ...
{% extends "admin/base.html" %}
{# admin/base.html is in
site-packages/django/contrib/admin/templates/admin #}
{% load i18n %}
{% block title %}{{ title }} | {% trans 'My site admin' %}{% endblock %}
{% block branding %}
<h1 id="site-name">{% trans 'My administration' %}</h1>
{% endblock %}
Note the comment which indicates that it inherits from the django tree
of admin templates.
How does django know to look at my base_site.html while it is processing
the django tree of templates?
The answer is simple and can be found in your settings.py file here ...
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
If the filesystem loader is ahead of the app_directories loader, django
looks in your project templates before its own. Here is the doc
reference ...
http://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types
Hope this helps
Mike
On 18/01/2011 12:26pm, Chen Xu wrote:
> I did try this, and I tried again, but it still doesn't work.
> Do I need to do something extra like quit the server, and restart again?
> By the way I did try this too.
>
> Now, I am totally lost.
>
> Thanks
>
> On Mon, Jan 17, 2011 at 3:17 AM, Vovk Donets <donets....@gmail.com
> <mailto:donets....@gmail.com>> wrote:
>
> You must specify in the TEMPLATE_DIRS path to the dir where
> templates were placed, not abs path file
> So
> TEMPLATE_DIRS = (
> "/Users/xuchen81/Django/mysite/",
>
> )
> should work, coz' "In order to override one or more of them, first
> create an admin directory in your project's templates directory.
> This can be any of the directories you specified in TEMPLATE_DIRS
> <http://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATE_DIRS>."
>
> 2011/1/17 Chen Xu <xuch...@gmail.com <mailto:xuch...@gmail.com>>
>
> Hi, Django group:
> I am floowing the tutorial 1 on Django site, which is a poll
> application
> I have problem with overriding the admin page
> I copied admin/base_site.html from
> (django/contrib/admin/templates) to
> /Users/xuchen81/Django/mysite/admin/base_site.html
>
> and add this line
> "/Users/xuchen81/Django/mysite/admin/base_site.html"
> to TEMPLATE_DIRS in my settings.py file. It looks like the
> following:
>
> TEMPLATE_DIRS = (
> "/Users/xuchen81/Django/mysite/admin/base_site.html",
> )
>
> but the admin is just doesn't use this file, it still uses the
> default base_site.html.
>
> Could anyone please help me?
>
> --
> *Vovk Donets*
> python/django developer
>
> skype: suunbeeam
> icq: 232490857
> mail: donets....@gmail.com <mailto:donets....@gmail.com>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>.
AND it is the only template in my PROJECT_DIR/templates/admin directory.
