Code

Opened 4 years ago

Closed 4 years ago

Last modified 15 months ago

#14342 closed Uncategorized (worksforme)

Part 2 of the Tutorial -- path format for TEMPLATE_DIR

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

Description

I've tried placing the default Django admin template into a custom directory of my choice (and modifying TEMPLATE_DIR accordingly). However, Django finds the template only if the template is in a specific directory (and TEMPLATE_DIR is modified accordingly): /path/to/mysite/polls/templates/admin

Python version = 2.6
Django = latest stable release
OS = Mac OS

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by gabrielhurley

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

Django should find the template provided the following:

  1. The template is named correctly,
  2. The template is in an admin directory
  3. The admin directory is within a directory named in your TEMPLATE_DIRS setting.

I believe the tutorial has proper instructions for accomplishing that if read carefully.

In your case, the template is being found at mysite/polls/templates/admin as you mention because the generic django.template.loaders.app_directories.load_template_source in TEMPLATE_LOADERS is finding it.

My guess is that you simply missed a detail in the tutorial or mistyped something in your paths.

If you still feel this is a problem, please give us more information about the directory you tried placing the template in, and what exactly your TEMPLATE_DIRS looked like?

comment:2 Changed 15 months ago by sheridb3@…

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

Hi there

I am having a similar problem. I have the following absolute path in the TEMPLATE_DIRS in settings.py: C:/Users/BernardWork/Documents/Work/WebStuff/mysite/admin/base_site.html

with base_site.html containing the edited admin name but the django.template.loaders.filesystem.Loader seems to be ignoring this path and using the location of the django source could base_site.html page. But when put inside my project mysite/polls/templates/admin it works and I know this is using the django.template.loaders.app_directories.load_template_source but it works while the other doesnt and I followed all instructions to the T. If you could get back to me on where I am going wrong I would really appreciate it. I am using a Windows 7 32- bit system and django 1.4.2 and python 2.7.

Many Thanks

Bernard

comment:3 Changed 15 months ago by timo

TEMPLATE_DIRS should be a list of directories, not files. So you would want 'C:/Users/BernardWork/Documents/Work/WebStuff/mysite/admin/' in your TEAMPLATE_DIRS. But, please don't use the ticket system for support issues. Please see https://docs.djangoproject.com/en/dev/#getting-help

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.