Code

Opened 9 years ago

Closed 7 years ago

Last modified 7 years ago

#279 closed defect (duplicate)

[patch] TemplateDoesNotExist on Windows

Reported by: garth@… Owned by: adrian
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: UI/UX:

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.

Attachments (0)

Change History (3)

comment:1 Changed 9 years ago by ned@…

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 Changed 7 years ago by Gary Wilson <gary.wilson@…>

  • Summary changed from TemplateDoesNotExist on Windows to [patch] TemplateDoesNotExist on Windows

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

  • Resolution set to duplicate
  • Status changed from new to closed

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

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.