Opened 13 years ago

Closed 12 years ago

Last modified 11 years ago

#279 closed defect (duplicate)

[patch] TemplateDoesNotExist on Windows

Reported by: garth@… Owned by: Adrian Holovaty
Component: contrib.admin Version: 1.1
Severity: normal Keywords: TemplateDoesNotExist windows escaping settings
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I just set up a project using the latest copy from the repository, and my settings/'s TEMPLATE_DIRS ended up containing someth

'C:\dev\django-svn runk\django\conf/admin_templates',

where the spaces indicate an actual tab. Oops! Replacing the line with


fixed the problem.

Change History (3)

comment:1 Changed 13 years ago by ned@…

A fix:

Index: django/core/
--- django/core/   (revision 493)
+++ django/core/   (working copy)
@@ -360,8 +360,10 @@
     # installed.
     admin_settings_file = os.path.join(directory, project_name, 'settings/')
     settings_contents = open(admin_settings_file, 'r').read()
-    fp = open(admin_settings_file, 'w')
-    settings_contents = re.sub(r'(?s)\b(TEMPLATE_DIRS\s*=\s*\()(.*?)\)', "\\1\n    '%s',\\2)" % ADMIN_TEMPLATE_DIR, settings_contents)
+    fp = open(admin_settings_file, 'w')
+    # In case we are on Windows, take care with backslashes.
+    admin_template_dir_escaped = ADMIN_TEMPLATE_DIR.replace('\\', '\\\\')
+    settings_contents = re.sub(r'(?s)\b(TEMPLATE_DIRS\s*=\s*\()(.*?)\)', "\\1\n    r'%s',\\2)" % admin_template_dir_escaped, settings_contents)
     # Create a random SECRET_KEY hash, and put it in the main settings.

comment:2 Changed 12 years ago by Gary Wilson <gary.wilson@…>

Summary: TemplateDoesNotExist on Windows[patch] TemplateDoesNotExist on Windows

comment:3 Changed 12 years ago by Gary Wilson <gary.wilson@…>

Resolution: duplicate
Status: newclosed

Duplicate of #93, which was fixed in [498].

Note: See TracTickets for help on using tickets.
Back to Top