-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmongodb_settings.py
32 lines (28 loc) · 1.07 KB
/
mongodb_settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
from django_mongodb_backend import parse_uri
if mongodb_uri := os.getenv("MONGODB_URI"):
db_settings = parse_uri(mongodb_uri, db_name="dummy")
# Workaround for https://github.com/mongodb-labs/mongo-orchestration/issues/268
if db_settings["USER"] and db_settings["PASSWORD"]:
db_settings["OPTIONS"].update({"tls": True, "tlsAllowInvalidCertificates": True})
DATABASES = {
"default": {**db_settings, "NAME": "djangotests"},
"other": {**db_settings, "NAME": "djangotests-other"},
}
else:
DATABASES = {
"default": {
"ENGINE": "django_mongodb_backend",
"NAME": "djangotests",
"OPTIONS": {"directConnection": True},
},
"other": {
"ENGINE": "django_mongodb_backend",
"NAME": "djangotests-other",
"OPTIONS": {"directConnection": True},
},
}
DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField"
PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",)
SECRET_KEY = "django_tests_secret_key"
USE_TZ = False