db_settings.py 592 B

123456789101112131415161718192021222324
  1. from pathlib import Path
  2. import os
  3. import core.config as conf
  4. BASE_DIR = Path(__file__).resolve().parent.parent
  5. if conf.DB_NAME is None:
  6. DATABASES = {
  7. 'default': {
  8. 'ENGINE': 'django.db.backends.sqlite3',
  9. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  10. }
  11. }
  12. else:
  13. DATABASES = {
  14. 'default': {
  15. 'ENGINE': 'django.db.backends.postgresql',
  16. 'NAME': conf.DB_NAME,
  17. 'USER': conf.DB_USER,
  18. 'PASSWORD': conf.DB_PASSWORD,
  19. 'HOST': conf.DB_HOST,
  20. 'PORT': '5432',
  21. }
  22. }