1
0
mirror of https://github.com/r4sas/py-i2phosts synced 2025-01-22 12:34:17 +00:00

Properly setup django in standalone scripts

https://docs.djangoproject.com/en/dev/releases/1.7/#standalone-scripts
This commit is contained in:
Hidden Z 2015-11-16 18:49:22 +00:00
parent 8905486e3e
commit 06468a3c7c
6 changed files with 12 additions and 0 deletions

View File

@ -35,6 +35,8 @@ else:
DJANGO_PROJECT_PATH = os.path.dirname(sys.argv[0]) + '/..'
sys.path.insert(1, DJANGO_PROJECT_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
import django
django.setup()
from pyi2phosts.postkey.models import i2phost
from pyi2phosts.lib.utils import validate_config

View File

@ -40,6 +40,8 @@ else:
DJANGO_PROJECT_PATH = os.path.dirname(sys.argv[0]) + '/..'
sys.path.insert(1, DJANGO_PROJECT_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
import django
django.setup()
from pyi2phosts.postkey.models import i2phost
from pyi2phosts.lib.utils import get_logger
from pyi2phosts.lib.utils import validate_config

View File

@ -43,6 +43,8 @@ else:
DJANGO_PROJECT_PATH = os.path.dirname(sys.argv[0]) + '/..'
sys.path.insert(1, DJANGO_PROJECT_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
import django
django.setup()
from pyi2phosts.lib.utils import get_logger
from pyi2phosts.lib.utils import validate_config
from pyi2phosts.extsources.models import ExternalSource

View File

@ -40,6 +40,8 @@ else:
DJANGO_PROJECT_PATH = os.path.dirname(sys.argv[0]) + '/..'
sys.path.insert(1, DJANGO_PROJECT_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
import django
django.setup()
from pyi2phosts.postkey.models import i2phost
from pyi2phosts.lib.validation import validate_hostname
from pyi2phosts.lib.validation import validate_b64hash

View File

@ -43,6 +43,8 @@ else:
DJANGO_PROJECT_PATH = os.path.dirname(sys.argv[0]) + '/..'
sys.path.insert(1, DJANGO_PROJECT_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
import django
django.setup()
from pyi2phosts.postkey.models import i2phost
from pyi2phosts.lib.utils import get_logger
from pyi2phosts.lib.utils import validate_config

View File

@ -128,6 +128,8 @@ else:
DJANGO_PROJECT_PATH = os.path.dirname(sys.argv[0]) + '/..'
sys.path.insert(1, DJANGO_PROJECT_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
import django
django.setup()
from pyi2phosts.lib.utils import get_logger
from pyi2phosts.lib.utils import validate_config