Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Metagenomics
metagenedb
Commits
88ab2352
Commit
88ab2352
authored
Jun 18, 2019
by
Kenzo-Hugo Hillion
♻
Browse files
modify settings organization for backend
parent
5389788c
Changes
7
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
88ab2352
...
...
@@ -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/
...
...
backend/.env.sample
0 → 100644
View file @
88ab2352
DEBUG=True
SECRET_KEY="your secret"
backend/metagenedb/apps/catalog/models/gene.py
View file @
88ab2352
...
...
@@ -9,4 +9,4 @@ class Gene(models.Model):
functions
=
models
.
ManyToManyField
(
Function
)
def
__str__
(
self
):
return
self
.
ge
ne_id
return
self
.
ge
backend/metagenedb/settings/__init__.py
0 → 100644
View file @
88ab2352
from
.django
import
*
# noqa
backend/metagenedb/settings/development.py
deleted
100644 → 0
View file @
5389788c
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'
,
)
backend/metagenedb/settings/
base
.py
→
backend/metagenedb/settings/
django
.py
View file @
88ab2352
"""
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'
)
backend/requirements.txt
View file @
88ab2352
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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment