Add host
[styx.blog] / styx / settings.py
1 """
2 Django settings for styx project.
3
4 Generated by 'django-admin startproject' using Django 3.1.
5
6 For more information on this file, see
7 https://docs.djangoproject.com/en/3.1/topics/settings/
8
9 For the full list of settings and their values, see
10 https://docs.djangoproject.com/en/3.1/ref/settings/
11 """
12
13 from pathlib import Path
14 import json
15 import os
16
17 # Build paths inside the project like this: BASE_DIR / 'subdir'.
18 BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
19
20
21 # Quick-start development settings - unsuitable for production
22 # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
23
24 try:
25     with open(os.path.expanduser('~/.styxrc'), 'r') as styxrc:
26         LOCAL_SETTINGS = json.loads(styxrc.read())
27
28 except FileNotFoundError:
29     LOCAL_SETTINGS = {}
30
31 # SECURITY WARNING: don't run with debug turned on in production!
32 DEBUG = LOCAL_SETTINGS.get('DEBUG', True)
33
34 if DEBUG:
35     SECRET_KEY = 'mq@_9a6&y4nvgqa7obf-r%a4^dt)z=r8jr&91&=oc^6-=i0*$z'
36 else:
37     SECRET_KEY = LOCAL_SETTINGS['SECRET_KEY']
38
39 ALLOWED_HOSTS = [
40     'localhost',
41     'www.localhost',
42     'styx.blog',
43     '46.101.172.187',
44 ]
45
46 # Application definition
47
48 INSTALLED_APPS = [
49     'django.contrib.admin',
50     'django.contrib.auth',
51     'django.contrib.contenttypes',
52     'django.contrib.sessions',
53     'django.contrib.messages',
54     'django.contrib.staticfiles',
55 ]
56
57 MIDDLEWARE = [
58     'django.middleware.security.SecurityMiddleware',
59     'django.contrib.sessions.middleware.SessionMiddleware',
60     'django.middleware.common.CommonMiddleware',
61     'django.middleware.csrf.CsrfViewMiddleware',
62     'django.contrib.auth.middleware.AuthenticationMiddleware',
63     'django.contrib.messages.middleware.MessageMiddleware',
64     'django.middleware.clickjacking.XFrameOptionsMiddleware',
65 ]
66
67 ROOT_URLCONF = 'styx.urls'
68
69 TEMPLATES = [
70     {
71         'BACKEND': 'django.template.backends.django.DjangoTemplates',
72         'DIRS': [],
73         'APP_DIRS': True,
74         'OPTIONS': {
75             'context_processors': [
76                 'django.template.context_processors.debug',
77                 'django.template.context_processors.request',
78                 'django.contrib.auth.context_processors.auth',
79                 'django.contrib.messages.context_processors.messages',
80             ],
81         },
82     },
83 ]
84
85 WSGI_APPLICATION = 'styx.wsgi.application'
86
87
88 # Database
89 # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
90
91 if DEBUG:
92     DATABASES = {
93         'default': {
94             'ENGINE': 'django.db.backends.sqlite3',
95             'NAME': BASE_DIR / 'db.sqlite3',
96         }
97     }
98 else:
99     DATABASES = {
100         'default': {
101             'ENGINE': 'django.db.backends.postgresql_psycopg2',
102             'NAME': 'styx',
103             'USER': 'styxuser',
104             'HOST': 'localhost',
105             'PASSWORD': LOCAL_SETTINGS['DB_PASSWORD'],
106         }
107     }
108
109
110 # Password validation
111 # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
112
113 AUTH_PASSWORD_VALIDATORS = [
114     {
115         'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
116     },
117     {
118         'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
119     },
120     {
121         'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
122     },
123     {
124         'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
125     },
126 ]
127
128
129 # Internationalization
130 # https://docs.djangoproject.com/en/3.1/topics/i18n/
131
132 LANGUAGE_CODE = 'en-us'
133
134 TIME_ZONE = 'UTC'
135
136 USE_I18N = True
137
138 USE_L10N = True
139
140 USE_TZ = True
141
142
143 # Static files (CSS, JavaScript, Images)
144 # https://docs.djangoproject.com/en/3.1/howto/static-files/
145
146 STATIC_URL = '/static/'
147 STATIC_ROOT = os.path.join(BASE_DIR, 'static/')