mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-15 14:17:43 +03:00
1732734ce5
It's currently not working well under Python 3.12
126 lines
4.9 KiB
Python
126 lines
4.9 KiB
Python
# ruff: noqa: E501
|
|
from .base import * # noqa: F403
|
|
from .base import INSTALLED_APPS
|
|
from .base import MIDDLEWARE
|
|
{%- if cookiecutter.frontend_pipeline == 'Webpack' %}
|
|
from .base import WEBPACK_LOADER
|
|
{%- endif %}
|
|
from .base import env
|
|
|
|
# GENERAL
|
|
# ------------------------------------------------------------------------------
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
|
DEBUG = True
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
|
SECRET_KEY = env(
|
|
"DJANGO_SECRET_KEY",
|
|
default="!!!SET DJANGO_SECRET_KEY!!!",
|
|
)
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
|
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"] # noqa: S104
|
|
|
|
# CACHES
|
|
# ------------------------------------------------------------------------------
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#caches
|
|
CACHES = {
|
|
"default": {
|
|
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
|
|
"LOCATION": "",
|
|
},
|
|
}
|
|
|
|
# EMAIL
|
|
# ------------------------------------------------------------------------------
|
|
{% if cookiecutter.use_mailpit == 'y' and cookiecutter.use_docker == 'y' -%}
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
|
|
EMAIL_HOST = env("EMAIL_HOST", default="mailpit")
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-port
|
|
EMAIL_PORT = 1025
|
|
{%- elif cookiecutter.use_mailpit == 'y' and cookiecutter.use_docker == 'n' -%}
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
|
|
EMAIL_HOST = "localhost"
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-port
|
|
EMAIL_PORT = 1025
|
|
{%- else -%}
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
|
|
EMAIL_BACKEND = env(
|
|
"DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend",
|
|
)
|
|
{%- endif %}
|
|
|
|
{%- if cookiecutter.use_whitenoise == 'y' %}
|
|
|
|
# WhiteNoise
|
|
# ------------------------------------------------------------------------------
|
|
# http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development
|
|
INSTALLED_APPS = ["whitenoise.runserver_nostatic", *INSTALLED_APPS]
|
|
{% endif %}
|
|
|
|
# django-debug-toolbar
|
|
# ------------------------------------------------------------------------------
|
|
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#prerequisites
|
|
INSTALLED_APPS += ["debug_toolbar"]
|
|
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#middleware
|
|
MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"]
|
|
# https://django-debug-toolbar.readthedocs.io/en/latest/configuration.html#debug-toolbar-config
|
|
DEBUG_TOOLBAR_CONFIG = {
|
|
"DISABLE_PANELS": [
|
|
"debug_toolbar.panels.redirects.RedirectsPanel",
|
|
# Disable profiling panel due to an issue with Python 3.12:
|
|
# https://github.com/jazzband/django-debug-toolbar/issues/1875
|
|
"debug_toolbar.panels.profiling.ProfilingPanel",
|
|
],
|
|
"SHOW_TEMPLATE_CONTEXT": True,
|
|
}
|
|
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips
|
|
INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"]
|
|
{% if cookiecutter.use_docker == 'y' -%}
|
|
if env("USE_DOCKER") == "yes":
|
|
import socket
|
|
|
|
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
|
|
INTERNAL_IPS += [".".join(ip.split(".")[:-1] + ["1"]) for ip in ips]
|
|
{%- if cookiecutter.frontend_pipeline in ['Gulp', 'Webpack'] %}
|
|
try:
|
|
_, _, ips = socket.gethostbyname_ex("node")
|
|
INTERNAL_IPS.extend(ips)
|
|
except socket.gaierror:
|
|
# The node container isn't started (yet?)
|
|
pass
|
|
{%- endif %}
|
|
{%- if cookiecutter.windows == 'y' %}
|
|
# RunServerPlus
|
|
# ------------------------------------------------------------------------------
|
|
# This is a custom setting for RunServerPlus to fix reloader issue in Windows docker environment
|
|
# Werkzeug reloader type [auto, watchdog, or stat]
|
|
RUNSERVERPLUS_POLLER_RELOADER_TYPE = 'stat'
|
|
# If you have CPU and IO load issues, you can increase this poller interval e.g) 5
|
|
RUNSERVERPLUS_POLLER_RELOADER_INTERVAL = 1
|
|
{%- endif %}
|
|
{%- endif %}
|
|
|
|
# django-extensions
|
|
# ------------------------------------------------------------------------------
|
|
# https://django-extensions.readthedocs.io/en/latest/installation_instructions.html#configuration
|
|
INSTALLED_APPS += ["django_extensions"]
|
|
{% if cookiecutter.use_celery == 'y' -%}
|
|
|
|
# Celery
|
|
# ------------------------------------------------------------------------------
|
|
{% if cookiecutter.use_docker == 'n' -%}
|
|
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#task-always-eager
|
|
CELERY_TASK_ALWAYS_EAGER = True
|
|
{%- endif %}
|
|
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#task-eager-propagates
|
|
CELERY_TASK_EAGER_PROPAGATES = True
|
|
|
|
{%- endif %}
|
|
{%- if cookiecutter.frontend_pipeline == 'Webpack' %}
|
|
# django-webpack-loader
|
|
# ------------------------------------------------------------------------------
|
|
WEBPACK_LOADER["DEFAULT"]["CACHE"] = not DEBUG
|
|
|
|
{%- endif %}
|
|
# Your stuff...
|
|
# ------------------------------------------------------------------------------
|