Skip to content

Commit 15d4f7f

Browse files
committed
added DJANGO_ENV support, basic database config and basic Makefile
1 parent adf4349 commit 15d4f7f

File tree

2 files changed

+38
-25
lines changed

2 files changed

+38
-25
lines changed

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
help:
4+
# First target is dummy so we you won't run anything by accident
5+
@echo "Hello world!, Please check the file content for details"
6+
7+
server:
8+
cd intbot && DJANGO_ENV="dev" uv run ./manage.py runserver 0.0.0.0:4672
9+
10+
migrate:
11+
cd intbot && DJANGO_ENV="dev" uv run ./manage.py migrate

intbot/intbot/settings.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,14 @@
1010
https://docs.djangoproject.com/en/5.1/ref/settings/
1111
"""
1212

13+
import os
1314
from pathlib import Path
1415

1516
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1617
BASE_DIR = Path(__file__).resolve().parent.parent
17-
18-
19-
# Quick-start development settings - unsuitable for production
20-
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
21-
22-
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = 'django-insecure'
24-
25-
# SECURITY WARNING: don't run with debug turned on in production!
26-
DEBUG = True
27-
2818
ALLOWED_HOSTS = []
2919

3020

31-
# Application definition
32-
3321
INSTALLED_APPS = [
3422
'django.contrib.admin',
3523
'django.contrib.auth',
@@ -70,17 +58,6 @@
7058
WSGI_APPLICATION = 'intbot.wsgi.application'
7159

7260

73-
# Database
74-
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
75-
76-
DATABASES = {
77-
'default': {
78-
'ENGINE': 'django.db.backends.sqlite3',
79-
'NAME': BASE_DIR / 'db.sqlite3',
80-
}
81-
}
82-
83-
8461
# Password validation
8562
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
8663

@@ -119,5 +96,30 @@
11996

12097
# Default primary key field type
12198
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
122-
12399
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
100+
101+
DJANGO_ENV = os.environ["DJANGO_ENV"]
102+
103+
if DJANGO_ENV == "dev":
104+
DEBUG = True
105+
ALLOWED_HOSTS = ["127.0.0.1", "localhost"]
106+
107+
SECRET_KEY = "django-insecure-secret"
108+
109+
DATABASES = {
110+
"default": {
111+
"ENGINE": "django.db.backends.postgresql",
112+
"NAME": "intbot_database_dev",
113+
"USER": "intbot_user",
114+
"PASSWORD": "intbot_password",
115+
"HOST": "localhost",
116+
"PORT": "14672",
117+
}
118+
}
119+
120+
elif DJANGO_ENV == "test":
121+
...
122+
123+
124+
else:
125+
raise ValueError(f"Unsupported DJANGO_ENV `{DJANGO_ENV}`")

0 commit comments

Comments
 (0)