Hi, I am sending my project file details ... Hope this helps
*Project Hierarchy*
mysite/
|--->/templates/
| |------->/books/(another app like dateapp)
| |------>/dateapp/
| | |---->*current_datetime.html*
| | |---->*hours_ahead.html*
| |-->*base.html*
|
|--->*settings.py*
--------------------------------------------------------------------
*current_datetime.html*
{% extends "base.html" %}
{% block title %}The current time{% endblock %}
{% block content %}
<p>It is now {{ current_date }}.</p>
{% endblock %}
---------------------------------------------------------------
my projects settings file TEMPLATE_DIR
*TEMPLATE_DIRS* = (
*os.path.join(os.path.dirname(__file__), 'templates').replace('\\','/'),*
# Put strings here, like "/home/html/django_templates" or
"C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
I my case template inheritance works quite fine. [?]
It is usually not recommended to meddle with admin app of django.
I hope instead of giving the path of the file in admin app, if you copy that
file (your base.html) in you project's template dir , it may help
On Tue, Jan 18, 2011 at 8:34 AM, Mike Dewhirst <[email protected]>wrote:
> On 18/01/2011 1:59pm, Mike Dewhirst wrote:
>
>> This is what I do ...
>>
>> 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 is the only template in my PROJECT_DIR/templates/admin directory.
>
>
>
> 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 <[email protected]
>>> <mailto:[email protected]>> 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 <[email protected] <mailto:[email protected]>>
>>>
>>> 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: [email protected] <mailto:[email protected]>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To post to this group, send email to [email protected]
>>> <mailto:[email protected]>.
>>> To unsubscribe from this group, send email to
>>> [email protected]<django-users%[email protected]>
>>> <mailto:django-users%[email protected]<django-users%[email protected]>
>>> >.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<django-users%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<django-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
<<330.gif>>

