tags:

views:

49

answers:

1

Hi I m following the tutorial on http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02 in windows 7 envoirement. my settings file is

TEMPLATE_DIRS = (
    'C:/django-project/myapp/mytemplates/admin'

)

i got the base_template from 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 myapp directory as the tutorial instructed.

It doesn't seem to take affect for some reason. Any clue of what might be the problem? Do i have to do a sync db ?

+4  A: 

I know this isn't in the django tutorial, and shame on them, but it's better to set up relative paths for your path variables. You can set it up like so:

import os

PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))

...

MEDIA_ROOT = PROJECT_PATH + '/media/'

TEMPLATE_DIRS = (
    PROJECT_PATH + '/templates/'
)

This way you can move your django project and your path roots will update automatically. This is useful when you're setting up your production server.

Second, there's something suspect to your TEMPLATE_DIRS path. It should point to the root of your template directory. Also, it should also end in a trailing /.

I'm just going to guess here that the .../admin/ directory is not your template root. If you still want to write absolute paths you should take out the reference to the admin template directory.

TEMPLATE_DIRS = (
    'C:/django-project/myapp/mytemplates/'
)

With that being said, the template loaders by default should be set up to recursively traverse into your app directories to locate template files.

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
#     'django.template.loaders.eggs.load_template_source',
)

You shouldn't need to copy over the admin templates unless if you specifically want to overwrite something.

You will have to run a syncdb if you haven't run it yet. You'll also need to statically server your media files if you're hosting django through runserver.

digitaldreamer
thanks alot removing "/admin" at the end of the TEMPLATE_DIRS relative path did it.