Skip to content

Commit 69e9d5b

Browse files
committed
Update example project for Django 1.6
1 parent 3e6d498 commit 69e9d5b

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/usr/bin/env python
2-
from django.core.management import execute_manager
3-
import imp
4-
try:
5-
imp.find_module('settings') # Assumed to be in the same directory.
6-
except ImportError:
7-
import sys
8-
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
9-
sys.exit(1)
2+
import sys
3+
import os
104

11-
import settings
5+
from settings import PROJECT_DIR, PROJECT_ROOT
6+
7+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../..'))
8+
os.chdir(PROJECT_ROOT)
9+
sys.path.insert(0, os.path.abspath(os.path.join(PROJECT_ROOT, "..")))
1210

1311
if __name__ == "__main__":
14-
execute_manager(settings)
12+
settings_module = "%s.settings" % PROJECT_DIR
13+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
14+
from django.core.management import execute_from_command_line
15+
execute_from_command_line(sys.argv)

django_socketio/example_project/settings.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
import os, sys
3+
34
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
5+
PROJECT_DIR = PROJECT_ROOT.split(os.sep)[-1]
6+
47
if PROJECT_ROOT not in sys.path:
58
sys.path.insert(0, PROJECT_ROOT)
69
full_path = lambda *parts: os.path.join(PROJECT_ROOT, *parts)
@@ -36,7 +39,7 @@
3639
)
3740

3841
STATIC_URL = "/static/"
39-
ROOT_URLCONF = "urls"
42+
ROOT_URLCONF = "%s.urls" % PROJECT_DIR
4043
TEMPLATE_DIRS = full_path("templates")
4144
#LOGIN_URL = "/admin/"
4245

@@ -49,3 +52,4 @@
4952
'django_socketio',
5053
'chat',
5154
)
55+

0 commit comments

Comments
 (0)