Hi all,

Attached is a patch against current svn (applies to 0.90 also), that
automatically sets TIME_ZONE and LANGUAGE_CODE according to the hosting
system.

Cheers,
-- 
Brett Parker
web:   http://www.sommitrealweird.co.uk/
email: [EMAIL PROTECTED]
Index: django/core/management.py
===================================================================
--- django/core/management.py   (revision 1298)
+++ django/core/management.py   (working copy)
@@ -2,7 +2,7 @@
 # development-server initialization.
 
 import django
-import os, re, sys
+import os, re, sys, locale
 
 MODULE_TEMPLATE = '''    {%% if perms.%(app)s.%(addperm)s or 
perms.%(app)s.%(changeperm)s %%}
     <tr>
@@ -465,6 +465,12 @@
     fp = open(main_settings_file, 'w')
     secret_key = ''.join([choice('[EMAIL PROTECTED]&*(-_=+)') for i in 
range(50)])
     settings_contents = re.sub(r"(?<=SECRET_KEY = ')'", secret_key + "'", 
settings_contents)
+    if os.access('/etc/timezone', R_OK):
+        tz = open('/etc/timezone', 'r').read().strip()
+        settings_contents = re.sub(r"(?<=TIME_ZONE = ').*'", tz + "'", 
settings_contents)
+    if local.getdefaultlocale()[0] != None:
+       langcode = re.sub(r"_", "-", locale.getdefaultlocale()[0])
+       settings_contents = re.sub(r"(?<=LANGUAGE_CODE = ').*'", langcode + 
"'", settings_contents)
     fp.write(settings_contents)
     fp.close()
 startproject.help_doc = "Creates a Django project directory structure for the 
given project name in the current directory."

Attachment: signature.asc
Description: Digital signature

Reply via email to