Load settings from .env file.
This commit is contained in:
parent
f221740228
commit
3efa217716
4 changed files with 31 additions and 13 deletions
16
.env.example
Normal file
16
.env.example
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Copy this file to .env and fill in the values
|
||||
# .env is gitignored and must never be committed
|
||||
|
||||
SECRET_KEY=change-me-to-a-long-random-string
|
||||
|
||||
# Set to True only for development
|
||||
DEBUG=False
|
||||
|
||||
# Comma-separated list of additional allowed hosts (beyond 127.0.0.1 and localhost)
|
||||
EXTRA_HOSTS=photos.crans.org,photos-dev.crans.org
|
||||
|
||||
# Comma-separated list of admins in "Name:email" format
|
||||
ADMINS=admin:photos-admin@lists.crans.org
|
||||
|
||||
# Email address used as sender for server emails
|
||||
SERVER_EMAIL=photos@crans.org
|
||||
|
|
@ -14,6 +14,7 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
|
|||
|
||||
import os
|
||||
|
||||
from decouple import Csv, config
|
||||
from django.contrib.messages import constants as messages
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
|
@ -25,17 +26,12 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = "CHANGE ME"
|
||||
SECRET_KEY = config("SECRET_KEY")
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
DEBUG = config("DEBUG", default=False, cast=bool)
|
||||
|
||||
ALLOWED_HOSTS = [
|
||||
"127.0.0.1",
|
||||
"localhost",
|
||||
"photos.crans.org",
|
||||
"photos-dev.crans.org",
|
||||
]
|
||||
ALLOWED_HOSTS = ["127.0.0.1", "localhost"] + config("EXTRA_HOSTS", default="", cast=Csv())
|
||||
|
||||
INTERNAL_IPS = [
|
||||
"127.0.0.1",
|
||||
|
|
@ -43,9 +39,8 @@ INTERNAL_IPS = [
|
|||
]
|
||||
|
||||
# Admins receive server errors, this is useful to be notified of potential bugs
|
||||
ADMINS = [
|
||||
("admin", "photos-admin@lists.crans.org"),
|
||||
]
|
||||
# Format: "Name:email,Name2:email2"
|
||||
ADMINS = [tuple(a.split(":")) for a in config("ADMINS", default="", cast=Csv()) if a]
|
||||
|
||||
# Use secure cookies in production
|
||||
SESSION_COOKIE_SECURE = not DEBUG
|
||||
|
|
@ -204,7 +199,7 @@ if DEBUG:
|
|||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||
|
||||
# Mail will be sent from this address
|
||||
SERVER_EMAIL = "photos@crans.org"
|
||||
SERVER_EMAIL = config("SERVER_EMAIL", default="photos@crans.org")
|
||||
DEFAULT_FROM_EMAIL = f"Serveur photos <{SERVER_EMAIL}>"
|
||||
EMAIL_SUBJECT_PREFIX = "[Serveur photos] "
|
||||
|
||||
|
|
|
|||
|
|
@ -224,8 +224,14 @@ class Gallery(models.Model):
|
|||
|
||||
class ImageModel(models.Model):
|
||||
image = models.ImageField(
|
||||
_("image"), max_length=IMAGE_FIELD_MAX_LENGTH, upload_to=get_storage_path
|
||||
_("image"),
|
||||
max_length=IMAGE_FIELD_MAX_LENGTH,
|
||||
upload_to=get_storage_path,
|
||||
width_field="image_width",
|
||||
height_field="image_height",
|
||||
)
|
||||
image_width = models.PositiveIntegerField(editable=False, null=True)
|
||||
image_height = models.PositiveIntegerField(editable=False, null=True)
|
||||
date_taken = models.DateTimeField(
|
||||
_("date taken"),
|
||||
null=True,
|
||||
|
|
|
|||
|
|
@ -5,3 +5,4 @@ django-select2>=4.8
|
|||
ExifRead>=2.1.2
|
||||
Pillow>=6.0.0
|
||||
django-debug-toolbar>=3.2.0
|
||||
python-decouple>=3.6
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue