mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-14 21:57:09 +03:00
86e33e8714
* Fix ./hooks/pre_gen_project.py asking user to select an option once only + prettify output * Fix pre_gen hook not really exiting when it should * Refactor & prettify ./hooks/post_gen_project.py * Ensure same POSTGRES_USER is set across environments + get rid of env.example in favor of pre-generated .env.
89 lines
3.0 KiB
Python
89 lines
3.0 KiB
Python
"""
|
|
Local settings for {{cookiecutter.project_name}} project.
|
|
|
|
- Run in Debug mode
|
|
{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'y' %}
|
|
- Use mailhog for emails via Docker
|
|
{% elif cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' %}
|
|
- Use mailhog for emails
|
|
{% else %}
|
|
- Use console backend for emails
|
|
{% endif %}
|
|
- Add Django Debug Toolbar
|
|
- Add django-extensions as app
|
|
"""
|
|
|
|
from .base import * # noqa
|
|
|
|
# DEBUG
|
|
# ------------------------------------------------------------------------------
|
|
DEBUG = env.bool('DJANGO_DEBUG', default=True)
|
|
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
|
|
|
# SECRET CONFIGURATION
|
|
# ------------------------------------------------------------------------------
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
|
# Note: This key only used for development and testing.
|
|
SECRET_KEY = env('DJANGO_SECRET_KEY', default='!!!SET DJANGO_SECRET_KEY!!!')
|
|
|
|
# Mail settings
|
|
# ------------------------------------------------------------------------------
|
|
|
|
EMAIL_PORT = 1025
|
|
{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'y' %}
|
|
EMAIL_HOST = env('EMAIL_HOST', default='mailhog')
|
|
{% elif cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' %}
|
|
EMAIL_HOST = 'localhost'
|
|
{% else %}
|
|
EMAIL_HOST = 'localhost'
|
|
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND',
|
|
default='django.core.mail.backends.console.EmailBackend')
|
|
{% endif %}
|
|
|
|
# CACHING
|
|
# ------------------------------------------------------------------------------
|
|
CACHES = {
|
|
'default': {
|
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
|
'LOCATION': ''
|
|
}
|
|
}
|
|
|
|
# django-debug-toolbar
|
|
# ------------------------------------------------------------------------------
|
|
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware', ]
|
|
INSTALLED_APPS += ['debug_toolbar', ]
|
|
|
|
INTERNAL_IPS = ['127.0.0.1', '10.0.2.2', ]
|
|
{% if cookiecutter.use_docker == 'y' %}
|
|
{# [cookiecutter-django] This is a workaround to flake8 "imported but unused" errors #}
|
|
import socket
|
|
import os
|
|
# tricks to have debug toolbar when developing with docker
|
|
if os.environ.get('USE_DOCKER') == 'yes':
|
|
ip = socket.gethostbyname(socket.gethostname())
|
|
INTERNAL_IPS += [ip[:-1] + '1']
|
|
{% endif %}
|
|
DEBUG_TOOLBAR_CONFIG = {
|
|
'DISABLE_PANELS': [
|
|
'debug_toolbar.panels.redirects.RedirectsPanel',
|
|
],
|
|
'SHOW_TEMPLATE_CONTEXT': True,
|
|
}
|
|
|
|
# django-extensions
|
|
# ------------------------------------------------------------------------------
|
|
INSTALLED_APPS += ['django_extensions', ]
|
|
|
|
# TESTING
|
|
# ------------------------------------------------------------------------------
|
|
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
|
{% if cookiecutter.use_celery == 'y' %}
|
|
########## CELERY
|
|
# In development, all tasks will be executed locally by blocking until the task returns
|
|
CELERY_ALWAYS_EAGER = True
|
|
########## END CELERY
|
|
{% endif %}
|
|
# Your local stuff: Below this line define 3rd party library settings
|
|
# ------------------------------------------------------------------------------
|