Integrate django-environ, to specify environment variables. #6
15
README.md
15
README.md
|
@ -4,6 +4,21 @@ Le but de cette application est de permettre une gestion des gymnastes tout au l
|
||||||
|
|
||||||
(plus d'information à venir)
|
(plus d'information à venir)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -r requirements/base.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
Par défaut, Khana est configuré pour tourner dans un environnement SQLite3. Pour spécifier l'emplacement de la base de données, utilisez l'une des syntaxes ci-dessous, et spécifiez-la dans le fichier `src/khana/.env`:
|
||||||
|
|
||||||
|
```text
|
||||||
|
# src/khana/.env
|
||||||
|
|
||||||
|
DATABASE_URL=mysql://user:password@127.0.0.1:3306/dbname
|
||||||
|
DATABASE_URL=psql://user:un-githubbedpassword@127.0.0.1:8458/database
|
||||||
|
```
|
||||||
|
|
||||||
Voici la liste des principaux modules.
|
Voici la liste des principaux modules.
|
||||||
|
|
||||||
## Objectifs
|
## Objectifs
|
||||||
|
|
|
@ -7,3 +7,6 @@ simplejson==3.17.0
|
||||||
Sphinx==2.4.1
|
Sphinx==2.4.1
|
||||||
django-extensions==2.2.8
|
django-extensions==2.2.8
|
||||||
djangorestframework==3.11.0
|
djangorestframework==3.11.0
|
||||||
|
|
||||||
|
django-environ==0.4.5
|
||||||
|
pendulum==2.1.2
|
||||||
|
|
|
@ -1,132 +0,0 @@
|
||||||
"""
|
|
||||||
Django settings for khana project.
|
|
||||||
|
|
||||||
Generated by 'django-admin startproject' using Django 1.8.2.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/1.8/topics/settings/
|
|
||||||
|
|
||||||
For the full list of settings and their values, see
|
|
||||||
https://docs.djangoproject.com/en/1.8/ref/settings/
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
||||||
import os
|
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
|
||||||
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
|
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
|
||||||
SECRET_KEY = "6@9p0g-5ebcttbt$^*s4rda5!piezt6b7wj35g(+$mgz52k#d="
|
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
|
||||||
DEBUG = True
|
|
||||||
ALLOWED_HOSTS = ["*"]
|
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
|
||||||
INSTALLED_APPS = (
|
|
||||||
"django.contrib.contenttypes",
|
|
||||||
"django.contrib.admin",
|
|
||||||
# 'django.contrib.admindocs',
|
|
||||||
"django.contrib.auth",
|
|
||||||
"django.contrib.sessions",
|
|
||||||
"django.contrib.messages",
|
|
||||||
"django.contrib.staticfiles",
|
|
||||||
"django_extensions",
|
|
||||||
"people",
|
|
||||||
"location",
|
|
||||||
"planning",
|
|
||||||
"objective",
|
|
||||||
"competition",
|
|
||||||
"profile",
|
|
||||||
"tools",
|
|
||||||
"communication",
|
|
||||||
"rest_framework",
|
|
||||||
# 'django_spaghetti',
|
|
||||||
)
|
|
||||||
|
|
||||||
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',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = "khana.urls"
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
||||||
"DIRS": [os.path.join(BASE_DIR, "templates"),],
|
|
||||||
"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",
|
|
||||||
"django.template.context_processors.media",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
# WSGI_APPLICATION = 'khana.wsgi.application'
|
|
||||||
|
|
||||||
|
|
||||||
# Database
|
|
||||||
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
"default": {
|
|
||||||
"ENGINE": "django.db.backends.sqlite3",
|
|
||||||
"NAME": "khana.db",
|
|
||||||
"USER": "",
|
|
||||||
"PASSWORD": "",
|
|
||||||
"HOST": "", # Or an IP Address that your DB is hosted on
|
|
||||||
"PORT": "",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Internationalization
|
|
||||||
# https://docs.djangoproject.com/en/1.8/topics/i18n/
|
|
||||||
|
|
||||||
# LANGUAGE_CODE = 'fr-FR' # en-US
|
|
||||||
LANGUAGE_CODE = "en-US"
|
|
||||||
|
|
||||||
TIME_ZONE = "UTC"
|
|
||||||
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
USE_L10N = True
|
|
||||||
|
|
||||||
USE_TZ = False # True
|
|
||||||
|
|
||||||
APPEND_SLASH = False # <== a mettre pour mes scripts des listes de présence ???
|
|
||||||
|
|
||||||
LOGIN_URL = "/login/"
|
|
||||||
|
|
||||||
LOGOUT_URL = "/logout/"
|
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
|
||||||
# https://docs.djangoproject.com/en/1.8/howto/static-files/
|
|
||||||
|
|
||||||
STATIC_URL = "/static/"
|
|
||||||
|
|
||||||
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)
|
|
||||||
|
|
||||||
MEDIA_URL = "/media/" # https://media.khana.be
|
|
||||||
|
|
||||||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
|
||||||
|
|
||||||
DEBUG_TOOLBAR_CONFIG = {
|
|
||||||
"JQUERY_URL": STATIC_URL + "js/jquery-2.1.4.min.js",
|
|
||||||
}
|
|
|
@ -1,17 +1,146 @@
|
||||||
import sys
|
"""
|
||||||
from khana.base_settings import *
|
Django settings for khana project.
|
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 1.8.2.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/1.8/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/1.8/ref/settings/
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
|
import os
|
||||||
|
|
||||||
|
import environ
|
||||||
|
|
||||||
|
|
||||||
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
env = environ.Env(
|
||||||
|
DEBUG=(bool, False)
|
||||||
|
)
|
||||||
|
|
||||||
|
environ.Env.read_env()
|
||||||
|
|
||||||
|
DEBUG = env('DEBUG', default=True)
|
||||||
|
|
||||||
|
SECRET_KEY = env('SECRET_KEY', default="6@9p0g-5ebcttbt$^*s4rda5!piezt6b7wj35g(+$mgz52k#d=")
|
||||||
|
|
||||||
|
# Parse database connection url strings like psql://user:pass@127.0.0.1:8458/db
|
||||||
|
DATABASES = {
|
||||||
|
'default': env.db('DATABASE_URL', default='sqlite:///db.sqlite3')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Quick-start development settings - unsuitable for production
|
||||||
|
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
|
||||||
|
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = ["*"]
|
||||||
|
|
||||||
|
|
||||||
|
# Application definition
|
||||||
|
INSTALLED_APPS = (
|
||||||
|
"django.contrib.contenttypes",
|
||||||
|
"django.contrib.admin",
|
||||||
|
# 'django.contrib.admindocs',
|
||||||
|
"django.contrib.auth",
|
||||||
|
"django.contrib.sessions",
|
||||||
|
"django.contrib.messages",
|
||||||
|
"django.contrib.staticfiles",
|
||||||
|
"django_extensions",
|
||||||
|
"people",
|
||||||
|
"location",
|
||||||
|
"planning",
|
||||||
|
"objective",
|
||||||
|
"competition",
|
||||||
|
"profile",
|
||||||
|
"tools",
|
||||||
|
"communication",
|
||||||
|
"rest_framework",
|
||||||
|
# 'django_spaghetti',
|
||||||
|
)
|
||||||
|
|
||||||
|
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',
|
||||||
|
]
|
||||||
|
|
||||||
|
ROOT_URLCONF = "khana.urls"
|
||||||
|
|
||||||
|
TEMPLATES = [
|
||||||
|
{
|
||||||
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||||
|
"DIRS": [os.path.join(BASE_DIR, "templates"),],
|
||||||
|
"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",
|
||||||
|
"django.template.context_processors.media",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
# WSGI_APPLICATION = 'khana.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
|
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
|
||||||
|
|
||||||
if not "test" in sys.argv:
|
DATABASES = {
|
||||||
DATABASES = {
|
|
||||||
"default": {
|
"default": {
|
||||||
"ENGINE": "django.db.backends.mysql",
|
"ENGINE": "django.db.backends.sqlite3",
|
||||||
"NAME": "khana",
|
"NAME": "khana.db",
|
||||||
"USER": "root",
|
"USER": "",
|
||||||
"PASSWORD": "PC8/aQy8+w3$",
|
"PASSWORD": "",
|
||||||
"HOST": "localhost", # Or an IP Address that your DB is hosted on
|
"HOST": "", # Or an IP Address that your DB is hosted on
|
||||||
"PORT": "3306",
|
"PORT": "",
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Internationalization
|
||||||
|
# https://docs.djangoproject.com/en/1.8/topics/i18n/
|
||||||
|
|
||||||
|
# LANGUAGE_CODE = 'fr-FR' # en-US
|
||||||
|
LANGUAGE_CODE = "en-US"
|
||||||
|
|
||||||
|
TIME_ZONE = "UTC"
|
||||||
|
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
USE_L10N = True
|
||||||
|
|
||||||
|
USE_TZ = False # True
|
||||||
|
|
||||||
|
APPEND_SLASH = False # <== a mettre pour mes scripts des listes de présence ???
|
||||||
|
|
||||||
|
LOGIN_URL = "/login/"
|
||||||
|
|
||||||
|
LOGOUT_URL = "/logout/"
|
||||||
|
|
||||||
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
# https://docs.djangoproject.com/en/1.8/howto/static-files/
|
||||||
|
|
||||||
|
STATIC_URL = "/static/"
|
||||||
|
|
||||||
|
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)
|
||||||
|
|
||||||
|
MEDIA_URL = "/media/" # https://media.khana.be
|
||||||
|
|
||||||
|
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||||
|
|
||||||
|
DEBUG_TOOLBAR_CONFIG = {
|
||||||
|
"JQUERY_URL": STATIC_URL + "js/jquery-2.1.4.min.js",
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue