From e4c13aee7dc39ae929a26df83b43dfd7d331a357 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Mon, 21 Apr 2014 11:06:37 +0800 Subject: [PATCH] Update manage.py to post a post-1.4 version. Django version 1.6 deprecates some of the django.core.management API, so we need a post-1.4 version. The semantics with app include paths have changed with this version, so update the urlconf to use the same path as manage.py. Signed-off-by: Jeremy Kerr --- apps/manage.py | 18 +++++++----------- apps/settings.py | 2 +- lib/apache2/patchwork.mod_python.conf | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/apps/manage.py b/apps/manage.py index 1f6f0ed..f9726f9 100755 --- a/apps/manage.py +++ b/apps/manage.py @@ -1,14 +1,10 @@ -#!/usr/bin/python - +#!/usr/bin/env python +import os import sys -from django.core.management import execute_manager -try: - import settings # Assumed to be in the same directory. -except ImportError: - import sys - 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(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) - sys.exit(1) - if __name__ == "__main__": - execute_manager(settings) + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/apps/settings.py b/apps/settings.py index 43a37d8..4bde26b 100644 --- a/apps/settings.py +++ b/apps/settings.py @@ -63,7 +63,7 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.csrf.CsrfViewMiddleware', ) -ROOT_URLCONF = 'apps.urls' +ROOT_URLCONF = 'urls' LOGIN_URL = '/user/login/' LOGIN_REDIRECT_URL = '/user/' diff --git a/lib/apache2/patchwork.mod_python.conf b/lib/apache2/patchwork.mod_python.conf index 6dbb09b..6395738 100644 --- a/lib/apache2/patchwork.mod_python.conf +++ b/lib/apache2/patchwork.mod_python.conf @@ -7,7 +7,7 @@ NameVirtualHost patchwork.example.com:80 SetHandler python-program PythonHandler django.core.handlers.modpython - PythonPath "['/srv/patchwork/apps', '/srv/patchwork', '/srv/patchwork/lib/python'] + sys.path" + PythonPath "['/srv/patchwork/apps', '/srv/patchwork/lib/python'] + sys.path" SetEnv DJANGO_SETTINGS_MODULE settings -- 2.39.5