Skip to content

Commit

Permalink
Updates simplify testproject settings (and fix them) (#1325)
Browse files Browse the repository at this point in the history
* Updates simplify testproject settings (and fix them)

* Set `SESSION_COOKIE_SECURE = False` explicitly for dev
  • Loading branch information
benjaoming committed Nov 9, 2023
1 parent d416db3 commit d8f23ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 33 deletions.
31 changes: 2 additions & 29 deletions testproject/testproject/settings/base.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
"""
Generated by 'django-admin startproject' using Django 1.9.5.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os

from django.urls import reverse_lazy
Expand Down Expand Up @@ -53,17 +44,17 @@

TEST_RUNNER = "django.test.runner.DiscoverRunner"


MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django.middleware.security.SecurityMiddleware",
]


ROOT_URLCONF = "testproject.urls"

TEMPLATES = [
Expand Down Expand Up @@ -103,24 +94,6 @@
}
}

# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]

# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/

Expand Down
10 changes: 6 additions & 4 deletions testproject/testproject/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@

DEBUG = True


for template_engine in TEMPLATES:
template_engine["OPTIONS"]["debug"] = True


EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

# Used by debug_toolbar
INTERNAL_IPS = ["127.0.0.1"]

ALLOWED_HOSTS = [
"localhost",
"0.0.0.0",
"127.0.0.1",
]
SESSION_COOKIE_DOMAIN = ".localhost"

# Removed.
# See: https://forum.djangoproject.com/t/why-are-cookie-secure-settings-defaulted-to-false/1133/4
# and https://github.com/django-wiki/django-wiki/pull/1325
# SESSION_COOKIE_DOMAIN = ".localhost"
SESSION_COOKIE_SECURE = False

try:
Expand All @@ -26,7 +29,6 @@
"debug_toolbar.middleware.DebugToolbarMiddleware",
]
INSTALLED_APPS = list(INSTALLED_APPS) + ["debug_toolbar"]
INTERNAL_IPS = ("127.0.0.1",)
DEBUG_TOOLBAR_CONFIG = {"INTERCEPT_REDIRECTS": False}
except ImportError:
pass

0 comments on commit d8f23ed

Please sign in to comment.