| 1 |
|
| 2 |
import os |
| 3 |
import sys |
| 4 |
|
| 5 |
|
| 6 |
try: |
| 7 |
from django.core.management import execute_manager |
| 8 |
|
| 9 |
OLD_DJANGO = True |
| 10 |
except ImportError: |
| 11 |
from django.core.management import execute_from_command_line |
| 12 |
|
| 13 |
OLD_DJANGO = False |
| 14 |
|
| 15 |
if OLD_DJANGO: |
| 16 |
try: |
| 17 |
import settings |
| 18 |
except ImportError: |
| 19 |
sys.stderr.write( |
| 20 |
"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(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" |
| 21 |
% __file__ |
| 22 |
) |
| 23 |
sys.exit(1) |
| 24 |
|
| 25 |
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
| 26 |
sys.path.insert(0, BASEDIR) |
| 27 |
|
| 28 |
if __name__ == "__main__": |
| 29 |
os.environ["DJANGO_SETTINGS_MODULE"] = "testproject.settings" |
| 30 |
if OLD_DJANGO: |
| 31 |
execute_manager(settings) |
| 32 |
else: |
| 33 |
execute_from_command_line(sys.argv) |