Opened 19 years ago

Closed 18 years ago

Last modified 17 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 admin.py
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

Description

I just set up a project using the latest copy from the repository, and my settings/admin.py'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

r'C:\dev\django-svn\trunk\django\conf\admin_templates',

fixed the problem.

Change History (3)

comment:1 by ned@…, 19 years ago

A fix:

Index: django/core/management.py
===================================================================
--- django/core/management.py   (revision 493)
+++ django/core/management.py   (working copy)
@@ -360,8 +360,10 @@
     # installed.
     admin_settings_file = os.path.join(directory, project_name, 'settings/admin.py')
     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)
     fp.write(settings_contents)
     fp.close()
     # Create a random SECRET_KEY hash, and put it in the main settings.

comment:2 by Gary Wilson <gary.wilson@…>, 18 years ago

Summary: TemplateDoesNotExist on Windows[patch] TemplateDoesNotExist on Windows

comment:3 by Gary Wilson <gary.wilson@…>, 18 years ago

Resolution: duplicate
Status: newclosed

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

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