From 8da2f0f041fd673748359c8a33f0e067ed138708 Mon Sep 17 00:00:00 2001 From: Andy Kittner Date: Fri, 27 Apr 2012 01:09:12 +0200 Subject: [PATCH] Fix start script broken by r550 Defer importing modules that require the DJANGO_SETTINGS_MODULE to be available until prepare_openslides() had a chance to set everything up. --- openslides/main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openslides/main.py b/openslides/main.py index b67c89a83..2a1ac79bc 100644 --- a/openslides/main.py +++ b/openslides/main.py @@ -22,10 +22,8 @@ import webbrowser from contextlib import nested import django.conf -from django.db import DatabaseError from django.core.management import execute_from_command_line from django.utils.crypto import get_random_string -from django.contrib.auth.models import User import openslides @@ -143,6 +141,10 @@ def run_syncdb(): def check_database(): """Detect if database was deleted and recreate if necessary""" + # can't be imported in global scope as they already require + # the settings module during import + from django.db import DatabaseError + from django.contrib.auth.models import User try: User.objects.count() @@ -153,7 +155,9 @@ def check_database(): return False def create_or_reset_admin_user(): - + # can't be imported in global scope as it already requires + # the settings module during import + from django.contrib.auth.models import User try: obj = User.objects.get(username = "admin") except User.DoesNotExist: