-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
734 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
POSTGRES_DB=mydjangodb | ||
POSTGRES_DB=mydb | ||
POSTGRES_USER=myuser | ||
POSTGRES_PASSWORD=mypassword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
DJ_ENV_NAME="local" | ||
DJ_SECRET_KEY="some-key-to-change-to-be-safe" | ||
DJ_DEBUG="true" | ||
DJ_DATABASE_URL="myuser:mypassword@localhost:5432/mydb" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dj_config.settings') | ||
|
||
application = get_asgi_application() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import os | ||
import sys | ||
from pathlib import Path | ||
import environ | ||
import dj_database_url | ||
|
||
########################################################################################## | ||
# Path | ||
########################################################################################## | ||
|
||
# Build paths inside the project like this: BASE_DIR / 'subdir'. | ||
BASE_DIR = Path(__file__).resolve().parent.parent | ||
|
||
APP_ROOT = "dj_apps" | ||
APPS_FOLDERS = [ | ||
APP_ROOT, | ||
# TODO: add f"{APP_ROOT}/<my_app_name>" for each new app | ||
] | ||
for folder in APPS_FOLDERS: | ||
sys.path.insert(0, os.path.join(BASE_DIR, folder)) | ||
|
||
|
||
########################################################################################## | ||
# Environment | ||
# https://django-environ.readthedocs.io/en/latest/quickstart.html | ||
########################################################################################## | ||
|
||
env = environ.Env() | ||
|
||
# Take environment variables from .env file (if it exists) | ||
# That's why it is important to NOT version .env file | ||
# (otherwise prod environment will get local env file values!) | ||
environ.Env.read_env(os.path.join(BASE_DIR, ".env")) | ||
|
||
ENV_NAME = env("DJ_ENV_NAME") | ||
|
||
########################################################################################## | ||
# Security | ||
########################################################################################## | ||
|
||
SECRET_KEY = env("DJ_SECRET_KEY") | ||
DEBUG = env("DJ_DEBUG", cast=bool) | ||
CORS_ORIGIN_ALLOW_ALL = True | ||
ALLOWED_HOSTS = ["*"] # To edit according your hosting platform | ||
|
||
|
||
########################################################################################## | ||
# Apps definition | ||
########################################################################################## | ||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
"corsheaders", | ||
] | ||
|
||
MIDDLEWARE = [ | ||
"django.middleware.security.SecurityMiddleware", | ||
"django.contrib.sessions.middleware.SessionMiddleware", | ||
"corsheaders.middleware.CorsMiddleware", # to handle CORS with right headers | ||
"django.middleware.common.CommonMiddleware", | ||
"django.middleware.csrf.CsrfViewMiddleware", | ||
"django.contrib.auth.middleware.AuthenticationMiddleware", | ||
"django.contrib.messages.middleware.MessageMiddleware", | ||
"django.middleware.clickjacking.XFrameOptionsMiddleware", | ||
] | ||
|
||
ROOT_URLCONF = "dj_config.urls" | ||
WSGI_APPLICATION = "dj_config.wsgi.application" | ||
|
||
|
||
########################################################################################## | ||
# Database | ||
# https://docs.djangoproject.com/en/dev/ref/settings/#databases | ||
########################################################################################## | ||
|
||
|
||
DATABASES = {"default": dj_database_url.config(env="DJ_DATABASE_URL", conn_max_age=600)} | ||
|
||
########################################################################################## | ||
# Internationalization | ||
# https://docs.djangoproject.com/en/dev/topics/i18n/ | ||
########################################################################################## | ||
|
||
LANGUAGE_CODE = "fr" | ||
TIME_ZONE = "Europe/Paris" | ||
USE_I18N = True | ||
USE_L10N = True | ||
USE_TZ = True | ||
|
||
########################################################################################## | ||
# Static files | ||
# https://docs.djangoproject.com/en/dev/howto/static-files/ | ||
########################################################################################## | ||
|
||
STATIC_URL = "/static/" | ||
STATIC_ROOT = BASE_DIR / "staticfiles" | ||
|
||
########################################################################################## | ||
# Misc | ||
########################################################################################## | ||
|
||
DEFAULT_AUTO_FIELD = "django.db.models.AutoField" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.contrib import admin | ||
from django.urls import path | ||
|
||
urlpatterns = [ | ||
path('dj_admin/', admin.site.urls), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import os | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dj_config.settings') | ||
|
||
application = get_wsgi_application() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
"""Django's command-line utility for administrative tasks.""" | ||
import os | ||
import sys | ||
|
||
|
||
def main(): | ||
"""Run administrative tasks.""" | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'toto.settings') | ||
try: | ||
from django.core.management import execute_from_command_line | ||
except ImportError as exc: | ||
raise ImportError( | ||
"Couldn't import Django. Are you sure it's installed and " | ||
"available on your PYTHONPATH environment variable? Did you " | ||
"forget to activate a virtual environment?" | ||
) from exc | ||
execute_from_command_line(sys.argv) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.