|
| 1 | +""" |
| 2 | +Django settings for mysite project. |
| 3 | +
|
| 4 | +Generated by 'django-admin startproject' using Django 2.1.1. |
| 5 | +
|
| 6 | +For more information on this file, see |
| 7 | +https://docs.djangoproject.com/en/2.1/topics/settings/ |
| 8 | +
|
| 9 | +For the full list of settings and their values, see |
| 10 | +https://docs.djangoproject.com/en/2.1/ref/settings/ |
| 11 | +""" |
| 12 | + |
| 13 | +import os |
| 14 | + |
| 15 | +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
| 16 | +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 17 | + |
| 18 | + |
| 19 | +# Quick-start development settings - unsuitable for production |
| 20 | +# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ |
| 21 | + |
| 22 | +# SECURITY WARNING: keep the secret key used in production secret! |
| 23 | +# Update the secret key to a value of your own before deploying the app. |
| 24 | +SECRET_KEY = 'lldtg$9(wi49j_hpv8nnqlh!cj7kmbwq0$rj7vy(b(b30vlyzj' |
| 25 | + |
| 26 | +# SECURITY WARNING: don't run with debug turned on in production! |
| 27 | +DEBUG = True |
| 28 | + |
| 29 | +# SECURITY WARNING: App Engine's security features ensure that it is safe to |
| 30 | +# have ALLOWED_HOSTS = ['*'] when the app is deployed. If you deploy a Django |
| 31 | +# app not on App Engine, make sure to set an appropriate host here. |
| 32 | +# See https://docs.djangoproject.com/en/2.1/ref/settings/ |
| 33 | +ALLOWED_HOSTS = ['*'] |
| 34 | + |
| 35 | + |
| 36 | +# Application definition |
| 37 | + |
| 38 | +INSTALLED_APPS = [ |
| 39 | + 'polls.apps.PollsConfig', |
| 40 | + 'django.contrib.admin', |
| 41 | + 'django.contrib.auth', |
| 42 | + 'django.contrib.contenttypes', |
| 43 | + 'django.contrib.sessions', |
| 44 | + 'django.contrib.messages', |
| 45 | + 'django.contrib.staticfiles', |
| 46 | +] |
| 47 | + |
| 48 | +MIDDLEWARE = [ |
| 49 | + 'django.middleware.security.SecurityMiddleware', |
| 50 | + 'django.contrib.sessions.middleware.SessionMiddleware', |
| 51 | + 'django.middleware.common.CommonMiddleware', |
| 52 | + 'django.middleware.csrf.CsrfViewMiddleware', |
| 53 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 54 | + 'django.contrib.messages.middleware.MessageMiddleware', |
| 55 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
| 56 | +] |
| 57 | + |
| 58 | +ROOT_URLCONF = 'mysite.urls' |
| 59 | + |
| 60 | +TEMPLATES = [ |
| 61 | + { |
| 62 | + 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
| 63 | + 'DIRS': [], |
| 64 | + 'APP_DIRS': True, |
| 65 | + 'OPTIONS': { |
| 66 | + 'context_processors': [ |
| 67 | + 'django.template.context_processors.debug', |
| 68 | + 'django.template.context_processors.request', |
| 69 | + 'django.contrib.auth.context_processors.auth', |
| 70 | + 'django.contrib.messages.context_processors.messages', |
| 71 | + ], |
| 72 | + }, |
| 73 | + }, |
| 74 | +] |
| 75 | + |
| 76 | +WSGI_APPLICATION = 'mysite.wsgi.application' |
| 77 | + |
| 78 | + |
| 79 | +# Database |
| 80 | +# https://docs.djangoproject.com/en/2.1/ref/settings/#databases |
| 81 | + |
| 82 | +# [START db_setup] |
| 83 | +if os.getenv('GAE_APPLICATION', None): |
| 84 | + # Running on production App Engine, so connect to Google Cloud SQL using |
| 85 | + # the unix socket at /cloudsql/<your-cloudsql-connection string> |
| 86 | + DATABASES = { |
| 87 | + 'default': { |
| 88 | + 'ENGINE': 'django.db.backends.mysql', |
| 89 | + 'HOST': '/cloudsql/[YOUR-CONNECTION-NAME]', |
| 90 | + 'USER': '[YOUR-USERNAME]', |
| 91 | + 'PASSWORD': '[YOUR-PASSWORD]', |
| 92 | + } |
| 93 | + } |
| 94 | +else: |
| 95 | + # Running locally so connect to either a local MySQL instance or connect to |
| 96 | + # Cloud SQL via the proxy. To start the proxy via command line: |
| 97 | + # |
| 98 | + # $ cloud_sql_proxy -instances=[INSTANCE_CONNECTION_NAME]=tcp:3306 |
| 99 | + # |
| 100 | + # See https://cloud.google.com/sql/docs/mysql-connect-proxy |
| 101 | + DATABASES = { |
| 102 | + 'default': { |
| 103 | + 'ENGINE': 'django.db.backends.mysql', |
| 104 | + 'HOST': '127.0.0.1', |
| 105 | + 'PORT': '3306', |
| 106 | + 'NAME': '[YOUR-DATABASE]', |
| 107 | + 'USER': '[YOUR-USERNAME]', |
| 108 | + 'PASSWORD': '[YOUR-PASSWORD]', |
| 109 | + } |
| 110 | + } |
| 111 | +# [END db_setup] |
| 112 | + |
| 113 | + |
| 114 | +# Password validation |
| 115 | +# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators |
| 116 | + |
| 117 | +AUTH_PASSWORD_VALIDATORS = [ |
| 118 | + { |
| 119 | + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', |
| 120 | + }, |
| 121 | + { |
| 122 | + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', |
| 123 | + }, |
| 124 | + { |
| 125 | + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', |
| 126 | + }, |
| 127 | + { |
| 128 | + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', |
| 129 | + }, |
| 130 | +] |
| 131 | + |
| 132 | + |
| 133 | +# Internationalization |
| 134 | +# https://docs.djangoproject.com/en/2.1/topics/i18n/ |
| 135 | + |
| 136 | +LANGUAGE_CODE = 'en-us' |
| 137 | + |
| 138 | +TIME_ZONE = 'UTC' |
| 139 | + |
| 140 | +USE_I18N = True |
| 141 | + |
| 142 | +USE_L10N = True |
| 143 | + |
| 144 | +USE_TZ = True |
| 145 | + |
| 146 | + |
| 147 | +# Static files (CSS, JavaScript, Images) |
| 148 | +# https://docs.djangoproject.com/en/2.1/howto/static-files/ |
| 149 | + |
| 150 | +STATIC_ROOT = 'static' |
| 151 | +STATIC_URL = '/static/' |
0 commit comments