bifurqué depuis cliss21/boiteaasso
build(base): mets à jour l'env. avec le cookiecutter
Parent
ed8b33e447
révision
0531d0db24
80
Makefile
80
Makefile
|
@ -3,8 +3,8 @@
|
|||
# Le nom de l'exécutable Python à utiliser ou son chemin absolu
|
||||
# (ex. : python ou python3).
|
||||
PYTHON_EXE := python3
|
||||
# S'il faut utiliser un environnement virtuel (yes ou no).
|
||||
USE_VENV := yes
|
||||
# S'il faut utiliser un environnement virtuel (y ou n).
|
||||
USE_VENV := y
|
||||
# Configuration de l'environnement virtuel.
|
||||
VENV_DIR := venv
|
||||
VENV_OPT := --system-site-packages
|
||||
|
@ -12,36 +12,64 @@ VENV_OPT := --system-site-packages
|
|||
# Définis les chemins et options des exécutables.
|
||||
PYTHON_EXE_BASENAME := $(shell basename $(PYTHON_EXE))
|
||||
VENV_PYTHON := --python=$(PYTHON_EXE_BASENAME)
|
||||
ifeq ($(USE_VENV), yes)
|
||||
ifeq ($(USE_VENV), y)
|
||||
PYTHON := $(VENV_DIR)/bin/$(PYTHON_EXE_BASENAME)
|
||||
PIP := $(VENV_DIR)/bin/pip
|
||||
FLAKE8 := $(VENV_DIR)/bin/flake8
|
||||
else
|
||||
PYTHON := $(shell which $(PYTHON_EXE))
|
||||
PIP := $(shell which pip)
|
||||
FLAKE8 := $(shell which flake8)
|
||||
endif
|
||||
|
||||
# Charge la configuration du 'config.env' s'il existe
|
||||
ifneq ("$(wildcard config.env)", "")
|
||||
include config.env
|
||||
endif
|
||||
# ... et définis l'environnement à utiliser.
|
||||
ifdef DJANGO_SETTINGS_MODULE
|
||||
ENV = $(shell echo $(DJANGO_SETTINGS_MODULE) | cut -d. -f3)
|
||||
# Détermine s'il faut charger le fichier de configuration.
|
||||
ifneq ($(READ_CONFIG_FILE), 0)
|
||||
READ_CONFIG_FILE := 1
|
||||
else
|
||||
ENV = production
|
||||
READ_CONFIG_FILE := 0
|
||||
endif
|
||||
|
||||
# Détermine l'environnement à utiliser.
|
||||
DEFAULT_ENV := production
|
||||
ifndef ENV
|
||||
ifeq ($(READ_CONFIG_FILE), 1)
|
||||
# Commence par chercher la dernière valeur de DJANGO_SETTINGS_MODULE,
|
||||
# puis de ENV s'il n'y en a pas, ou utilise l'environnement par défaut.
|
||||
ENV = $(shell \
|
||||
sed -n -e '/^DJANGO_SETTINGS_MODULE/s/[^.]*\.settings\.\([^.]*\)/\1/p' \
|
||||
-e '/^ENV/s/[^=]*=\(.*\)/\1/p' config.env 2> /dev/null \
|
||||
| tail -n 1 | grep -Ee '^..*' || echo "$(DEFAULT_ENV)")
|
||||
else
|
||||
ifdef DJANGO_SETTINGS_MODULE
|
||||
ENV = $(shell echo $(DJANGO_SETTINGS_MODULE) | cut -d. -f3)
|
||||
else
|
||||
ENV := $(DEFAULT_ENV)
|
||||
endif # ifdef DJANGO_SETTINGS_MODULE
|
||||
endif # ifeq READ_CONFIG_FILE
|
||||
endif # ifndef ENV
|
||||
|
||||
# Définis EDITOR pour l'édition interactive.
|
||||
ifndef EDITOR
|
||||
ifdef VISUAL
|
||||
EDITOR := $(VISUAL)
|
||||
else
|
||||
EDITOR := vi
|
||||
endif
|
||||
endif
|
||||
|
||||
# Définition des cibles -------------------------------------------------------
|
||||
|
||||
.PHONY: clean-pyc clean-build clear-venv help
|
||||
.PHONY: clean-pyc clean-build clear-venv help check check-config
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
# commentaire d'une cible : #-> interne ##-> aide production+dev ###-> aide dev
|
||||
# Commentaire d'une cible : #-> interne ##-> aide production+dev ###-> aide dev
|
||||
help: ## affiche cette aide
|
||||
ifeq ($(ENV), production)
|
||||
@perl -nle'print $& if m{^[a-zA-Z_-]+:[^#]*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
||||
@perl -nle'print $& if m{^[a-zA-Z_-]+:[^#]*?## .*$$}' $(MAKEFILE_LIST) \
|
||||
| sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
||||
else
|
||||
@perl -nle'print $& if m{^[a-zA-Z_-]+:[^#]*?###? .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?###? "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
||||
@perl -nle'print $& if m{^[a-zA-Z_-]+:[^#]*?###? .*$$}' $(MAKEFILE_LIST) \
|
||||
| sort | awk 'BEGIN {FS = ":.*?###? "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
||||
endif
|
||||
|
||||
clean: clean-build clean-pyc ## nettoie tous les fichiers temporaires
|
||||
|
@ -58,14 +86,26 @@ clean-pyc: ### nettoie les fichiers temporaires python
|
|||
|
||||
init: create-venv config.env update ## initialise l'environnement et l'application
|
||||
|
||||
config.env: # TODO: lancer une commande interactive
|
||||
config.env:
|
||||
ifeq ($(READ_CONFIG_FILE), 1)
|
||||
cp config.env.example config.env
|
||||
chmod go-rwx config.env
|
||||
$(EDITOR) config.env
|
||||
endif
|
||||
|
||||
update: install-deps migrate static ## mets à jour l'application et ses dépendances
|
||||
update: check-config install-deps migrate static ## mets à jour l'application et ses dépendances
|
||||
touch boiteaasso/wsgi.py
|
||||
|
||||
check: check-config ## vérifie la configuration de l'instance
|
||||
$(PYTHON) manage.py check
|
||||
|
||||
check-config:
|
||||
@find . -maxdepth 1 -name config.env -perm /o+rwx -exec false {} + || \
|
||||
{ echo "\033[31mErreur :\033[0m les permissions de config.env ne sont pas bonnes, \
|
||||
vous devriez au moins faire : chmod o-rwx config.env"; false; }
|
||||
|
||||
install-deps: ## installe les dépendances de l'application
|
||||
$(PIP) install -U -r requirements/$(ENV).txt
|
||||
$(PIP) install --upgrade --requirement requirements/$(ENV).txt
|
||||
|
||||
migrate: ## mets à jour le schéma de la base de données
|
||||
$(PYTHON) manage.py migrate
|
||||
|
@ -81,7 +121,7 @@ endif
|
|||
create-venv: $(PYTHON)
|
||||
|
||||
$(PYTHON):
|
||||
ifeq ($(USE_VENV), yes)
|
||||
ifeq ($(USE_VENV), y)
|
||||
virtualenv $(VENV_OPT) $(VENV_PYTHON) $(VENV_DIR)
|
||||
else
|
||||
@echo "\033[31mErreur !\033[0m Impossible de trouver l'exécutable Python $(PYTHON)"
|
||||
|
@ -101,4 +141,4 @@ serve: ### démarre un serveur local pour l'application
|
|||
$(PYTHON) manage.py runserver
|
||||
|
||||
lint: ### vérifie la syntaxe et le code python
|
||||
flake8 boiteaasso
|
||||
$(FLAKE8) boiteaasso
|
||||
|
|
|
@ -1 +1,22 @@
|
|||
from .base import * # noqa
|
||||
import environ
|
||||
|
||||
"""The default environment to use."""
|
||||
DEFAULT_ENVIRONMENT = 'production'
|
||||
|
||||
"""The environment variables of the app instance."""
|
||||
env = environ.Env()
|
||||
|
||||
"""Path to the package root - e.g. Django project."""
|
||||
root_dir = environ.Path(__file__) - 2
|
||||
|
||||
"""Path to the base directory of the app instance."""
|
||||
base_dir = env.path('BASE_DIR', default=str(root_dir - 1))
|
||||
|
||||
# Load config.env, OS environment variables will take precedence
|
||||
if env.bool('READ_CONFIG_FILE', default=True):
|
||||
env.read_env(str(base_dir.path('config.env')))
|
||||
|
||||
"""The Django settings module's name to use."""
|
||||
DJANGO_SETTINGS_MODULE = env(
|
||||
'DJANGO_SETTINGS_MODULE', default='boiteaasso.settings.{}'.format(env(
|
||||
'ENV', default=DEFAULT_ENVIRONMENT)))
|
||||
|
|
|
@ -9,23 +9,12 @@ https://docs.djangoproject.com/en/stable/ref/settings/
|
|||
"""
|
||||
import os.path
|
||||
|
||||
import environ
|
||||
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
from . import env, base_dir, root_dir
|
||||
|
||||
# ENVIRONMENT VARIABLES AND PATHS
|
||||
# ------------------------------------------------------------------------------
|
||||
# Load environment variables
|
||||
env = environ.Env()
|
||||
|
||||
# Package - e.g. Django project - root and apps directories
|
||||
root_dir = environ.Path(__file__) - 2
|
||||
apps_dir = root_dir.path('apps')
|
||||
|
||||
# Base directory of the app instance
|
||||
# Note that it should be defined in OS environment variables in case of a
|
||||
# multi-instances application.
|
||||
base_dir = env.path('BASE_DIR', default=str(root_dir - 1))
|
||||
|
||||
# Local directory used for static and templates overrides
|
||||
local_dir = base_dir.path('local')
|
||||
|
@ -35,12 +24,6 @@ var_dir = base_dir.path('var')
|
|||
if not os.path.isdir(var_dir()):
|
||||
os.mkdir(var_dir(), mode=0o755)
|
||||
|
||||
# Whether config.env should be loaded here
|
||||
READ_CONFIG_FILE = env.bool('DJANGO_READ_CONFIG_FILE', default=True)
|
||||
if READ_CONFIG_FILE:
|
||||
# OS environment variables take precedence over variables from config.env
|
||||
env.read_env(str(base_dir.path('config.env')))
|
||||
|
||||
# Location on which the application is served
|
||||
APP_LOCATION = env('APP_LOCATION', default='/')
|
||||
|
||||
|
@ -82,7 +65,7 @@ ROOT_URLCONF = 'boiteaasso.urls'
|
|||
# https://docs.djangoproject.com/en/stable/ref/settings/#wsgi-application
|
||||
WSGI_APPLICATION = 'boiteaasso.wsgi.application'
|
||||
|
||||
# APPS
|
||||
# APP CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
DJANGO_APPS = [
|
||||
'registration',
|
||||
|
@ -93,14 +76,14 @@ DJANGO_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
# Django's extensions
|
||||
'tapeforms',
|
||||
]
|
||||
|
||||
THIRD_PARTY_APPS = [
|
||||
# Wagtail's applications
|
||||
WAGTAIL_APPS = [
|
||||
'wagtail.contrib.forms',
|
||||
'wagtail.contrib.modeladmin',
|
||||
'wagtail.contrib.redirects',
|
||||
'wagtail.contrib.routable_page',
|
||||
'wagtail.contrib.settings',
|
||||
'wagtail.embeds',
|
||||
'wagtail.sites',
|
||||
'wagtail.users',
|
||||
|
@ -110,16 +93,19 @@ THIRD_PARTY_APPS = [
|
|||
'wagtail.search',
|
||||
'wagtail.admin',
|
||||
'wagtail.core',
|
||||
'wagtail.contrib.modeladmin',
|
||||
'wagtail.contrib.routable_page',
|
||||
'wagtail.contrib.settings',
|
||||
# Wagtail's dependencies
|
||||
'modelcluster',
|
||||
'taggit',
|
||||
]
|
||||
|
||||
# Project dependencies
|
||||
THIRD_PARTY_APPS = [
|
||||
'tapeforms',
|
||||
# Wagtail's extensions
|
||||
'wagtailmenus',
|
||||
]
|
||||
|
||||
# Project applications
|
||||
LOCAL_APPS = [
|
||||
'boiteaasso.base',
|
||||
'boiteaasso.accounts',
|
||||
|
@ -128,7 +114,7 @@ LOCAL_APPS = [
|
|||
]
|
||||
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#installed-apps
|
||||
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
||||
INSTALLED_APPS = DJANGO_APPS + WAGTAIL_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
||||
|
||||
# AUTHENTICATION
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -202,7 +188,6 @@ STATIC_URL = os.path.join(APP_LOCATION, 'static/')
|
|||
STATICFILES_DIRS = [
|
||||
root_dir('static'),
|
||||
]
|
||||
|
||||
if os.path.isdir(local_dir('static')):
|
||||
STATICFILES_DIRS.insert(0, local_dir('static'))
|
||||
|
||||
|
@ -256,7 +241,6 @@ TEMPLATES = [
|
|||
},
|
||||
},
|
||||
]
|
||||
|
||||
if os.path.isdir(local_dir('templates')):
|
||||
TEMPLATES[0]['DIRS'].insert(0, local_dir('templates'))
|
||||
|
||||
|
@ -296,6 +280,21 @@ SESSION_COOKIE_PATH = APP_LOCATION
|
|||
# https://docs.djangoproject.com/en/stable/ref/settings/#csrf-cookie-path
|
||||
CSRF_COOKIE_PATH = APP_LOCATION
|
||||
|
||||
# WAGTAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
# http://docs.wagtail.io/en/stable/advanced_topics/settings.html
|
||||
WAGTAIL_SITE_NAME = "Boite à Asso"
|
||||
|
||||
# Disable Gravatar provider
|
||||
WAGTAIL_GRAVATAR_PROVIDER_URL = None
|
||||
|
||||
WAGTAIL_USER_CREATION_FORM = (
|
||||
'boiteaasso.accounts.forms.WagtailAccountCreationForm'
|
||||
)
|
||||
WAGTAIL_USER_EDIT_FORM = (
|
||||
'boiteaasso.accounts.forms.WagtailAccountEditForm'
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# APPLICATION AND 3RD PARTY LIBRARY SETTINGS
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -305,20 +304,6 @@ CSRF_COOKIE_PATH = APP_LOCATION
|
|||
# http://django-registration-redux.readthedocs.io/en/v2.2/default-backend.html
|
||||
ACCOUNT_ACTIVATION_DAYS = 5
|
||||
|
||||
# WAGTAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
# http://docs.wagtail.io/en/stable/advanced_topics/settings.html
|
||||
WAGTAIL_SITE_NAME = "Boite à Asso"
|
||||
WAGTAIL_USER_CREATION_FORM = (
|
||||
'boiteaasso.accounts.forms.WagtailAccountCreationForm'
|
||||
)
|
||||
WAGTAIL_USER_EDIT_FORM = (
|
||||
'boiteaasso.accounts.forms.WagtailAccountEditForm'
|
||||
)
|
||||
|
||||
# Disable Gravatar provider
|
||||
WAGTAIL_GRAVATAR_PROVIDER_URL = None
|
||||
|
||||
# WAGTAIL EMBEDS
|
||||
# ------------------------------------------------------------------------------
|
||||
# http://docs.wagtail.io/en/stable/advanced_topics/embeds.html#customising-embed-providers
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
"""
|
||||
Development settings.
|
||||
|
||||
- set debug mode to `True` by default
|
||||
- use Console backend for emails sending by default
|
||||
- add the django-debug-toolbar
|
||||
"""
|
||||
|
@ -27,6 +26,11 @@ ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=[
|
|||
vars().update(env.email_url(
|
||||
'DJANGO_EMAIL_URL', default='consolemail://'))
|
||||
|
||||
# WAGTAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
# http://docs.wagtail.io/en/stable/contributing/styleguide.html
|
||||
INSTALLED_APPS += ['wagtail.contrib.styleguide'] # noqa: F405
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# APPLICATION AND 3RD PARTY LIBRARY SETTINGS
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -52,8 +56,3 @@ DEBUG_TOOLBAR_CONFIG = {
|
|||
# ------------------------------------------------------------------------------
|
||||
# https://django-extensions.readthedocs.io/en/stable/index.html
|
||||
INSTALLED_APPS += ['django_extensions'] # noqa: F405
|
||||
|
||||
# WAGTAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
# http://docs.wagtail.io/en/stable/contributing/styleguide.html
|
||||
INSTALLED_APPS += ['wagtail.contrib.styleguide'] # noqa: F405
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
Production settings.
|
||||
|
||||
- validate the configuration
|
||||
- disable debug mode
|
||||
- load secret key from environment variables
|
||||
- set other production configurations
|
||||
"""
|
||||
|
|
|
@ -10,12 +10,10 @@ import os
|
|||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
|
||||
# if running multiple sites in the same mod_wsgi process. To fix this, use
|
||||
# mod_wsgi daemon mode with each site in its own daemon process, or use
|
||||
# os.environ["DJANGO_SETTINGS_MODULE"] = "boiteaasso.settings.production"
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
|
||||
'boiteaasso.settings.production')
|
||||
from boiteaasso.settings import DJANGO_SETTINGS_MODULE
|
||||
|
||||
# Set the default settings module to use.
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', DJANGO_SETTINGS_MODULE)
|
||||
|
||||
# This application object is used by any WSGI server configured to use this
|
||||
# file. This includes Django's development server, if the WSGI_APPLICATION
|
||||
|
|
|
@ -1,37 +1,80 @@
|
|||
# Base directory of the app instance, where the local and var folders are
|
||||
# located. Default is the current directory.
|
||||
# BASE_DIR=
|
||||
|
||||
# Database configuration as an URL.
|
||||
# /!\ It must be set in production.
|
||||
# DJANGO_DATABASE_URL=psql://user:password@127.0.0.1:8458/boiteaasso
|
||||
|
||||
# Email configuration as an URL. Default is the local SMTP server in
|
||||
# production and the console in development.
|
||||
# DJANGO_EMAIL_URL=smtp+tls://localhost:587
|
||||
|
||||
# Default email address to use for various automated correspondence.
|
||||
# /!\ It must be set in production.
|
||||
# DEFAULT_FROM_EMAIL=webmaster@example.org
|
||||
###########################################################
|
||||
# #
|
||||
# Edit the following configuration to suits your needs. #
|
||||
# #
|
||||
###########################################################
|
||||
|
||||
# Environment to use within the application.
|
||||
# Note that if you want to change the default value, this variable should be
|
||||
# either set by your uWSGI server or defined in your OS environment.
|
||||
# DJANGO_SETTINGS_MODULE=boiteaasso.settings.production
|
||||
#
|
||||
# The environment is used to load the proper settings for your application
|
||||
# instance. There is two ways for defining it, with the following precedence:
|
||||
# - DJANGO_SETTINGS_MODULE: the Python path to the settings module to use. It
|
||||
# allows you to define and use your own settings module. Use it with care!
|
||||
# Note: the module name will be used as the environment.
|
||||
# - ENV: the environment to use, which is one of 'production' or 'development'.
|
||||
#
|
||||
# Default is the 'production' environment.
|
||||
#ENV=production
|
||||
#ENV=development
|
||||
|
||||
# The secret key used to provide cryptographic signing. It should be set to
|
||||
# a unique, unpredictable value. On a GNU/Linux system, you could generate a
|
||||
# new one with:
|
||||
# $ head -c50 /dev/urandom | base64
|
||||
# /!\ It must be set in production.
|
||||
# DJANGO_SECRET_KEY=CHANGEME!!!
|
||||
# The secret key used to provide cryptographic signing.
|
||||
#
|
||||
# It should be set to a unique, unpredictable value. On a GNU/Linux system, you
|
||||
# could generate a new one with:
|
||||
#
|
||||
# $ head -c50 /dev/urandom | base64
|
||||
#
|
||||
# /!\ Required in production.
|
||||
#DJANGO_SECRET_KEY=CHANGEME!!!
|
||||
|
||||
# A coma-separated string representing the host/domain names that this Django
|
||||
# site can serve.
|
||||
# DJANGO_ALLOWED_HOSTS=example.org,
|
||||
# A coma-separated string representing the host/domain names that this
|
||||
# application instance can serve.
|
||||
#
|
||||
# /!\ Required in production.
|
||||
#DJANGO_ALLOWED_HOSTS=example.org,
|
||||
|
||||
# Turn on/off debug mode. Note that it's always disabled in production.
|
||||
# DJANGO_DEBUG=off
|
||||
# Database configuration, as an URI.
|
||||
#
|
||||
# In production, the recommended database backend for better performances is
|
||||
# PostgreSQL - or MySQL if you prefer.
|
||||
#
|
||||
# Default is a SQLite database in development only.
|
||||
#
|
||||
# /!\ Required in production.
|
||||
#DJANGO_DATABASE_URL=postgres://user:password@127.0.0.1:5432/boiteaasso
|
||||
#DJANGO_DATABASE_URL=mysql://user:password@127.0.0.1:3306/boiteaasso
|
||||
|
||||
# Location on which the application is served.
|
||||
# APP_LOCATION=/
|
||||
# Email configuration for sending messages, as an URI.
|
||||
#
|
||||
# In production, you should either use a local SMTP server or a relay one. The
|
||||
# following protocols are supported:
|
||||
# - SMTP: smtp://
|
||||
# - SMTP+SSL: smtp+ssl://
|
||||
# - SMTP+TLS: smtp+tls://
|
||||
#
|
||||
# Default is the local SMTP server in production and the console in development.
|
||||
#DJANGO_EMAIL_URL=smtp://localhost:25
|
||||
|
||||
# Default email address to use for various automated correspondence.
|
||||
#
|
||||
# /!\ Required in production.
|
||||
#DEFAULT_FROM_EMAIL=webmaster@example.org
|
||||
|
||||
# URL prefix on which the application is served.
|
||||
#
|
||||
# This is used to generate the static and media URLs, but also links to the
|
||||
# application which require an absolute URL.
|
||||
#
|
||||
# Default is '/', e.g. at the domain root.
|
||||
#APP_LOCATION=/
|
||||
|
||||
# Base directory of the app instance, where the local and var folders are
|
||||
# located.
|
||||
#
|
||||
# Default is the current directory.
|
||||
#BASE_DIR=
|
||||
|
||||
# Turn on/off debug mode.
|
||||
#
|
||||
# Note that it's always disabled in production.
|
||||
#DJANGO_DEBUG=off
|
||||
|
|
28
manage.py
28
manage.py
|
@ -2,35 +2,25 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
import environ
|
||||
|
||||
DEFAULT_DJANGO_SETTINGS_MODULE = 'boiteaasso.settings.production'
|
||||
from boiteaasso.settings import DJANGO_SETTINGS_MODULE
|
||||
|
||||
if __name__ == "__main__":
|
||||
env = environ.Env()
|
||||
|
||||
# Charge la configuration définie dans config.env
|
||||
if (env.bool('DJANGO_READ_CONFIG_FILE', default=True) and
|
||||
os.path.isfile('config.env')):
|
||||
env.read_env('config.env')
|
||||
|
||||
# Définis la valeur par défaut pour le module de settings
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', env(
|
||||
'DJANGO_SETTINGS_MODULE', default=DEFAULT_DJANGO_SETTINGS_MODULE
|
||||
))
|
||||
# Set the default settings module to use.
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', DJANGO_SETTINGS_MODULE)
|
||||
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError:
|
||||
# L'importation pouvant échouer pour une raison quelconque, on s'assure
|
||||
# que le problème vient vraiment du fait que Django n'est pas installé.
|
||||
# The above import may fail for some other reason. Ensure that the
|
||||
# issue is really that Django is missing to avoid masking other
|
||||
# exceptions on Python 2.
|
||||
try:
|
||||
import django # noqa
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Impossible d'importer Django. Êtes-vous sûr qu'il est "
|
||||
"installé dans votre environnement ou que celui-ci est "
|
||||
"bien activé ?"
|
||||
"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?"
|
||||
)
|
||||
raise
|
||||
|
||||
|
|
Chargement…
Référencer dans un nouveau ticket