Fakultas Ilmu Komputer UI

settings.py 3.99 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
"""
Django settings for superlists project.

Generated by 'django-admin startproject' using Django 1.10.5.

For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""

import os
Muhammad Ilham Peruzzi's avatar
Muhammad Ilham Peruzzi committed
14
15
16
import psycopg2
import dj_database_url

17
18

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Muhammad Ilham Peruzzi's avatar
Muhammad Ilham Peruzzi committed
19
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
20
21
22
23
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
Muhammad Ilham Peruzzi's avatar
Muhammad Ilham Peruzzi committed
24
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
25
26
27
28
29

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'ex5rgq_jg@bc653ieniy@=)n%x6ek^3-e)n=o7^i#4z%rvu7zp'

# SECURITY WARNING: don't run with debug turned on in production!
30
DEBUG = False
31

Muhammad Ilham Peruzzi's avatar
Muhammad Ilham Peruzzi committed
32
ALLOWED_HOSTS = ['*']
33
34
35
36
37


# Application definition

INSTALLED_APPS = [
38
    #'django.contrib.admin',
39
40
41
42
43
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
44
    'lists',
45
46
    'sass_processor',
    'django_mutpy'
47
48
49
50
51
52
53
54
55
56
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
Muhammad Ilham Peruzzi's avatar
Muhammad Ilham Peruzzi committed
57
    'whitenoise.middleware.WhiteNoiseMiddleware',
58
59
60
61
62
63
64
]

ROOT_URLCONF = 'superlists.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
65
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'superlists.wsgi.application'


# Database
Muhammad Ilham Peruzzi's avatar
Muhammad Ilham Peruzzi committed
82
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
83
84
85
86
87
88
89
90

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

Muhammad Ilham Peruzzi's avatar
Muhammad Ilham Peruzzi committed
91
92
93
94
95
96
97
98
99
# Use PostgreSql as default database on production
DATABASE_URL = os.environ.get('DATABASE_URL')

if DATABASE_URL is not None:
    print("Database URL", DATABASE_URL)
    conn = psycopg2.connect(DATABASE_URL, sslmode='require')
    DATABASES['default'] = dj_database_url.config(conn_max_age=600, 
                                                  ssl_require=True)

100
101

# Password validation
Muhammad Ilham Peruzzi's avatar
Muhammad Ilham Peruzzi committed
102
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
Muhammad Ilham Peruzzi's avatar
Muhammad Ilham Peruzzi committed
121
# https://docs.djangoproject.com/en/2.1/topics/i18n/
122
123
124
125
126
127
128
129
130
131
132
133
134

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
Muhammad Ilham Peruzzi's avatar
Muhammad Ilham Peruzzi committed
135
# https://docs.djangoproject.com/en/2.1/howto/static-files/
136
137

STATIC_URL = '/static/'
Muhammad Ilham Peruzzi's avatar
Muhammad Ilham Peruzzi committed
138
139
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
140
141
142
143
144
145
146

SASS_PROCESSOR_ROOT = os.path.join(PROJECT_DIR, 'static')
STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'sass_processor.finders.CssFinder',
]