Commit 88ab2352 authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

modify settings organization for backend

parent 5389788c
......@@ -3,11 +3,8 @@ __pycache__/
.env
.idea/
# Backend
## For settings
backend/metagenedb/settings/__init__.py
## Static files
backend/static
# Backend static files
backend/public
# Jupyter notebook
notebooks/
......
DEBUG=True
SECRET_KEY="your secret"
......@@ -9,4 +9,4 @@ class Gene(models.Model):
functions = models.ManyToManyField(Function)
def __str__(self):
return self.gene_id
return self.ge
from .django import * # noqa
from .base import *
INSTALLED_APPS = INSTALLED_APPS + [
'django_extensions',
'corsheaders',
]
MIDDLEWARE = MIDDLEWARE + [
'corsheaders.middleware.CorsMiddleware',
]
# CORS
CORS_ORIGIN_ALLOW_ALL = False
CORS_ORIGIN_WHITELIST = (
'http://localhost:8080',
)
"""
Django settings for metagenedb project.
import environ
Generated by 'django-admin startproject' using Django 2.2.2.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
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/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '01^q5^z**8vfdd$u4&b0w!2thaj=3b93+i*v$&kwmz6&ix6x8)'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# This can be used to toggle between your local testing db (db.sqlite3) and the PostgreSQL backend:
DOCKER = os.environ.get('WEB_DOCKER', False)
if DEBUG:
# This value is not safe for production usage. Refer to the Django documentation for more information.
ALLOWED_HOSTS = ['*']
root = environ.Path(__file__) - 3 # get root of the project
env = environ.Env()
environ.Env.read_env(root('.env')) # reading .env file
# Application definition
......@@ -44,6 +17,8 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'django_extensions',
'corsheaders',
]
MIDDLEWARE = [
......@@ -54,6 +29,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware',
]
ROOT_URLCONF = 'metagenedb.urls'
......@@ -77,31 +53,6 @@ TEMPLATES = [
WSGI_APPLICATION = 'metagenedb.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
if DOCKER:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'postgres',
'USER': 'postgres',
'HOST': 'db',
'PORT': 5432,
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'postgres',
'USER': 'postgres',
'HOST': 'localhost',
'PORT': 5433,
}
}
# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
......@@ -135,8 +86,32 @@ USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
# CORS
CORS_ORIGIN_ALLOW_ALL = False
CORS_ORIGIN_WHITELIST = (
'http://localhost:8080',
)
# Config by .env file
DEBUG = env.bool('DEBUG', default=False)
TEMPLATE_DEBUG = DEBUG
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'postgres',
'USER': 'postgres',
'HOST': env.str('DATABASES_HOST', default='db'),
'PORT': env.str('POSTGRES_PORT', default=5432),
}
}
public_root = root.path('public/')
MEDIA_ROOT = public_root('media')
MEDIA_URL = env.str('MEDIA_URL', default='media/')
STATIC_ROOT = public_root('static')
STATIC_URL = env.str('STATIC_URL', default='/static/')
STATIC_URL = '/static/'
STATIC_ROOT = 'static'
SECRET_KEY = env.str('SECRET_KEY')
Django==2.2.1
django-cors-headers==3.0.2
django-extensions==2.1.7
django-environ
djangorestframework==3.9.4
psycopg2==2.8.2
pytz==2019.1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment