From 94c232c7750721b0603906c9159cb98c0f164854 Mon Sep 17 00:00:00 2001 From: expoonserver Date: Sun, 17 Jun 2018 02:23:02 +0100 Subject: [PATCH] django.setup needs to be run before any attempt to use database --- databaseReset.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/databaseReset.py b/databaseReset.py index 3b01b87..f520a09 100644 --- a/databaseReset.py +++ b/databaseReset.py @@ -2,12 +2,12 @@ import os import time import settings os.environ['PYTHONPATH'] = settings.PYTHON_PATH -os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings') from django.core import management from django.db import connection from django.contrib.auth.models import User from django.http import HttpResponse -from django.core.urlresolvers import reverse +from django.core.urlresolvers import reverse from troggle.core.models import Cave, Entrance import troggle.flatpages.models @@ -187,6 +187,8 @@ def usage(): if __name__ == "__main__": import troggle.core.models import sys + import django + django.setup() if "desc" in sys.argv: resetdesc() elif "scans" in sys.argv: