Make database location variable

This commit is contained in:
Jeff Bogatay 2016-08-23 12:18:28 -04:00
parent 2a1818d09a
commit 93fb1be253

View File

@ -31,6 +31,11 @@ LOGIN_URL = '/admin/login'
ALLOWED_HOSTS = [] ALLOWED_HOSTS = []
# Tap paperless.conf if it's available
if os.path.exists("/etc/paperless.conf"):
load_dotenv("/etc/paperless.conf")
# Application definition # Application definition
@ -90,9 +95,10 @@ WSGI_APPLICATION = 'paperless.wsgi.application'
DATABASES = { DATABASES = {
"default": { "default": {
"ENGINE": "django.db.backends.sqlite3", "ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "..", "data", "db.sqlite3"), "NAME": os.path.join(os.getenv("PAPERLESS_DBLOCATION",os.path.join(BASE_DIR, "..", "data")), "db.sqlite3")
} }
} }
print(DATABASES)
if os.getenv("PAPERLESS_DBUSER") and os.getenv("PAPERLESS_DBPASS"): if os.getenv("PAPERLESS_DBUSER") and os.getenv("PAPERLESS_DBPASS"):
DATABASES["default"] = { DATABASES["default"] = {
"ENGINE": "django.db.backends.postgresql_psycopg2", "ENGINE": "django.db.backends.postgresql_psycopg2",
@ -150,11 +156,6 @@ MEDIA_URL = "/media/"
# values in /etc/paperless.conf instead. # values in /etc/paperless.conf instead.
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Tap paperless.conf if it's available
if os.path.exists("/etc/paperless.conf"):
load_dotenv("/etc/paperless.conf")
# Logging # Logging
LOGGING = { LOGGING = {