We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Restore SessionAuthenticationMiddleware
We aim to move away from having a heavy JavaScript front-end, preferring instead to use Django templates (and sprinkles of JS where needed). This means we can use SessionAuthenticationMiddleware.

This will also require restoring the default authentication classes in `settings.py`

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `project/core/settings.py`
Content:
```
1 """
2 Django settings for civiwiki project.
3 Darius Calliet May 12, 2016
4 
5 Production settings file to select proper environment variables.
6 """
7 import os
8 
9 # False if not in os.environ
10 DEBUG = os.getenv("DEBUG", False)
11 
12 # defaults to second value if not found in os.environ
13 DJANGO_HOST = os.getenv("DJANGO_HOST", "LOCALHOST")
14 
15 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
16 SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", "TEST_KEY_FOR_DEVELOPMENT")
17 ALLOWED_HOSTS = [".herokuapp.com", ".civiwiki.org", "127.0.0.1", "localhost", "0.0.0.0"]
18 
19 INSTALLED_APPS = (
20     "django.contrib.admin",
21     "django.contrib.auth",
22     "django.contrib.contenttypes",
23     "django.contrib.sessions",
24     "django.contrib.messages",
25     "django.contrib.staticfiles",
26     "django_extensions",
27     "storages",
28     "core",  # TODO: consider removing this, if we can move the decorators, etc. to an actual app
29     "api",
30     "rest_framework",
31     "accounts",
32     "threads",
33     "frontend_views",
34     "notifications",
35     "corsheaders",
36     "taggit",
37 )
38 
39 MIDDLEWARE = [
40     "corsheaders.middleware.CorsMiddleware",
41     "django.middleware.security.SecurityMiddleware",
42     "whitenoise.middleware.WhiteNoiseMiddleware",
43     "django.contrib.sessions.middleware.SessionMiddleware",
44     "django.middleware.common.CommonMiddleware",
45     "django.middleware.csrf.CsrfViewMiddleware",
46     "django.contrib.auth.middleware.AuthenticationMiddleware",
47     # 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
48     "django.contrib.messages.middleware.MessageMiddleware",
49     "django.middleware.clickjacking.XFrameOptionsMiddleware",
50 ]
51 
52 CSRF_USE_SESSIONS = (
53     True  # Store the CSRF token in the users session instead of in a cookie
54 )
55 
56 CORS_ORIGIN_ALLOW_ALL = True
57 ROOT_URLCONF = "core.urls"
58 LOGIN_URL = "/login"
59 
60 # SSL Setup
61 if DJANGO_HOST != "LOCALHOST":
62     SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
63     SECURE_SSL_REDIRECT = True
64     SESSION_COOKIE_SECURE = True
65     CSRF_COOKIE_SECURE = True
66 
67 # Internationalization & Localization
68 LANGUAGE_CODE = "en-us"
69 TIME_ZONE = "UTC"
70 USE_I18N = True
71 USE_L10N = True
72 USE_TZ = True
73 
74 TEMPLATES = [
75     {
76         "BACKEND": "django.template.backends.django.DjangoTemplates",
77         "DIRS": [
78             os.path.join(BASE_DIR, "threads/templates/threads"), os.path.join(BASE_DIR, "accounts/templates/accounts")
79         ],  # TODO: Add non-webapp template directory
80         "APP_DIRS": True,
81         "OPTIONS": {
82             "context_processors": [
83                 "django.template.context_processors.debug",
84                 "django.template.context_processors.request",
85                 "django.contrib.auth.context_processors.auth",
86                 "django.contrib.messages.context_processors.messages",
87             ],
88         },
89     },
90 ]
91 
92 WSGI_APPLICATION = "core.wsgi.application"
93 
94 # Apex Contact for Production Errors
95 ADMINS = [("Development Team", "dev@civiwiki.org")]
96 
97 # AWS S3 Setup
98 if "AWS_STORAGE_BUCKET_NAME" not in os.environ:
99     MEDIA_URL = "/media/"
100     MEDIA_ROOT = os.path.join(BASE_DIR, "media")
101 else:
102     AWS_STORAGE_BUCKET_NAME = os.getenv("AWS_STORAGE_BUCKET_NAME")
103     AWS_S3_ACCESS_KEY_ID = os.getenv("AWS_S3_ACCESS_KEY_ID")
104     AWS_S3_SECRET_ACCESS_KEY = os.getenv("AWS_S3_SECRET_ACCESS_KEY")
105     DEFAULT_FILE_STORAGE = "storages.backends.s3boto.S3BotoStorage"
106     AWS_S3_SECURE_URLS = False
107     AWS_QUERYSTRING_AUTH = False
108 
109 STATIC_URL = "/static/"
110 STATICFILES_DIRS = (os.path.join(BASE_DIR, "threads/templates/static"),)
111 STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
112 
113 # TODO: re-organize and simplify staticfiles settings
114 if "CIVIWIKI_LOCAL_NAME" not in os.environ:
115     STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
116 
117 # Use DATABASE_URL in production
118 DATABASE_URL = os.getenv("DATABASE_URL")
119 
120 if DATABASE_URL is not None:
121     DATABASES = {"default": DATABASE_URL}
122 else:
123     # Default to sqlite for simplicity in development
124     DATABASES = {
125         "default": {
126             "ENGINE": "django.db.backends.sqlite3",
127             "NAME": BASE_DIR + "/" + "db.sqlite3",
128         }
129     }
130 
131 # Email Backend Setup
132 if "EMAIL_HOST" not in os.environ:
133     EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
134     EMAIL_HOST_USER = "test@civiwiki.org"
135 else:
136     EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
137     EMAIL_HOST = os.getenv("EMAIL_HOST")
138     EMAIL_PORT = os.getenv("EMAIL_PORT")
139     EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
140     EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
141     EMAIL_USE_SSL = True
142     DEFAULT_FROM_EMAIL = EMAIL_HOST
143 
144 # Notification API Settings
145 NOTIFICATIONS_SOFT_DELETE = True
146 NOTIFICATIONS_USE_JSONFIELD = True
147 
148 # Django REST API Settings
149 DEFAULT_RENDERER_CLASSES = ("rest_framework.renderers.JSONRenderer",)
150 
151 DEFAULT_AUTHENTICATION_CLASSES = ("rest_framework.authentication.BasicAuthentication",)
152 
153 if DEBUG:
154     # Browsable HTML - Enabled only in Debug mode (dev)
155     DEFAULT_RENDERER_CLASSES = DEFAULT_RENDERER_CLASSES + (
156         "rest_framework.renderers.BrowsableAPIRenderer",
157     )
158 
159     DEFAULT_AUTHENTICATION_CLASSES = (
160         "api.authentication.CsrfExemptSessionAuthentication",
161     ) + DEFAULT_AUTHENTICATION_CLASSES
162 
163 REST_FRAMEWORK = {
164     "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
165     "DEFAULT_RENDERER_CLASSES": DEFAULT_RENDERER_CLASSES,
166     "DEFAULT_AUTHENTICATION_CLASSES": DEFAULT_AUTHENTICATION_CLASSES,
167 }
168 
169 # CORS Settings
170 CORS_ORIGIN_ALLOW_ALL = True
171 
172 # Custom User model
173 AUTH_USER_MODEL = 'accounts.User'
174 
175 APPEND_SLASH = False
176 
177 DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
178 
179 LOGIN_REDIRECT_URL = '/'
180 
181 AUTH_PASSWORD_VALIDATORS = [
182     {
183         'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
184     },
185     {
186         'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
187         'OPTIONS': {
188             'min_length': 8,
189         }
190     },
191     {
192         'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
193     },
194     {
195         'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
196     },
197 ]
198
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/project/core/settings.py b/project/core/settings.py
--- a/project/core/settings.py
+++ b/project/core/settings.py
@@ -148,7 +148,7 @@
 # Django REST API Settings
 DEFAULT_RENDERER_CLASSES = ("rest_framework.renderers.JSONRenderer",)
 
-DEFAULT_AUTHENTICATION_CLASSES = ("rest_framework.authentication.BasicAuthentication",)
+DEFAULT_AUTHENTICATION_CLASSES = ("rest_framework.authentication.SessionAuthentication",)
 
 if DEBUG:
     # Browsable HTML - Enabled only in Debug mode (dev)

{"golden_diff": "diff --git a/project/core/settings.py b/project/core/settings.py\n--- a/project/core/settings.py\n+++ b/project/core/settings.py\n@@ -148,7 +148,7 @@\n # Django REST API Settings\n DEFAULT_RENDERER_CLASSES = (\"rest_framework.renderers.JSONRenderer\",)\n \n-DEFAULT_AUTHENTICATION_CLASSES = (\"rest_framework.authentication.BasicAuthentication\",)\n+DEFAULT_AUTHENTICATION_CLASSES = (\"rest_framework.authentication.SessionAuthentication\",)\n \n if DEBUG:\n     # Browsable HTML - Enabled only in Debug mode (dev)\n", "issue": "Restore SessionAuthenticationMiddleware\nWe aim to move away from having a heavy JavaScript front-end, preferring instead to use Django templates (and sprinkles of JS where needed). This means we can use SessionAuthenticationMiddleware.\r\n\r\nThis will also require restoring the default authentication classes in `settings.py`\n", "before_files": [{"content": "\"\"\"\nDjango settings for civiwiki project.\nDarius Calliet May 12, 2016\n\nProduction settings file to select proper environment variables.\n\"\"\"\nimport os\n\n# False if not in os.environ\nDEBUG = os.getenv(\"DEBUG\", False)\n\n# defaults to second value if not found in os.environ\nDJANGO_HOST = os.getenv(\"DJANGO_HOST\", \"LOCALHOST\")\n\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\nSECRET_KEY = os.getenv(\"DJANGO_SECRET_KEY\", \"TEST_KEY_FOR_DEVELOPMENT\")\nALLOWED_HOSTS = [\".herokuapp.com\", \".civiwiki.org\", \"127.0.0.1\", \"localhost\", \"0.0.0.0\"]\n\nINSTALLED_APPS = (\n    \"django.contrib.admin\",\n    \"django.contrib.auth\",\n    \"django.contrib.contenttypes\",\n    \"django.contrib.sessions\",\n    \"django.contrib.messages\",\n    \"django.contrib.staticfiles\",\n    \"django_extensions\",\n    \"storages\",\n    \"core\",  # TODO: consider removing this, if we can move the decorators, etc. to an actual app\n    \"api\",\n    \"rest_framework\",\n    \"accounts\",\n    \"threads\",\n    \"frontend_views\",\n    \"notifications\",\n    \"corsheaders\",\n    \"taggit\",\n)\n\nMIDDLEWARE = [\n    \"corsheaders.middleware.CorsMiddleware\",\n    \"django.middleware.security.SecurityMiddleware\",\n    \"whitenoise.middleware.WhiteNoiseMiddleware\",\n    \"django.contrib.sessions.middleware.SessionMiddleware\",\n    \"django.middleware.common.CommonMiddleware\",\n    \"django.middleware.csrf.CsrfViewMiddleware\",\n    \"django.contrib.auth.middleware.AuthenticationMiddleware\",\n    # 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',\n    \"django.contrib.messages.middleware.MessageMiddleware\",\n    \"django.middleware.clickjacking.XFrameOptionsMiddleware\",\n]\n\nCSRF_USE_SESSIONS = (\n    True  # Store the CSRF token in the users session instead of in a cookie\n)\n\nCORS_ORIGIN_ALLOW_ALL = True\nROOT_URLCONF = \"core.urls\"\nLOGIN_URL = \"/login\"\n\n# SSL Setup\nif DJANGO_HOST != \"LOCALHOST\":\n    SECURE_PROXY_SSL_HEADER = (\"HTTP_X_FORWARDED_PROTO\", \"https\")\n    SECURE_SSL_REDIRECT = True\n    SESSION_COOKIE_SECURE = True\n    CSRF_COOKIE_SECURE = True\n\n# Internationalization & Localization\nLANGUAGE_CODE = \"en-us\"\nTIME_ZONE = \"UTC\"\nUSE_I18N = True\nUSE_L10N = True\nUSE_TZ = True\n\nTEMPLATES = [\n    {\n        \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n        \"DIRS\": [\n            os.path.join(BASE_DIR, \"threads/templates/threads\"), os.path.join(BASE_DIR, \"accounts/templates/accounts\")\n        ],  # TODO: Add non-webapp template directory\n        \"APP_DIRS\": True,\n        \"OPTIONS\": {\n            \"context_processors\": [\n                \"django.template.context_processors.debug\",\n                \"django.template.context_processors.request\",\n                \"django.contrib.auth.context_processors.auth\",\n                \"django.contrib.messages.context_processors.messages\",\n            ],\n        },\n    },\n]\n\nWSGI_APPLICATION = \"core.wsgi.application\"\n\n# Apex Contact for Production Errors\nADMINS = [(\"Development Team\", \"dev@civiwiki.org\")]\n\n# AWS S3 Setup\nif \"AWS_STORAGE_BUCKET_NAME\" not in os.environ:\n    MEDIA_URL = \"/media/\"\n    MEDIA_ROOT = os.path.join(BASE_DIR, \"media\")\nelse:\n    AWS_STORAGE_BUCKET_NAME = os.getenv(\"AWS_STORAGE_BUCKET_NAME\")\n    AWS_S3_ACCESS_KEY_ID = os.getenv(\"AWS_S3_ACCESS_KEY_ID\")\n    AWS_S3_SECRET_ACCESS_KEY = os.getenv(\"AWS_S3_SECRET_ACCESS_KEY\")\n    DEFAULT_FILE_STORAGE = \"storages.backends.s3boto.S3BotoStorage\"\n    AWS_S3_SECURE_URLS = False\n    AWS_QUERYSTRING_AUTH = False\n\nSTATIC_URL = \"/static/\"\nSTATICFILES_DIRS = (os.path.join(BASE_DIR, \"threads/templates/static\"),)\nSTATIC_ROOT = os.path.join(BASE_DIR, \"staticfiles\")\n\n# TODO: re-organize and simplify staticfiles settings\nif \"CIVIWIKI_LOCAL_NAME\" not in os.environ:\n    STATICFILES_STORAGE = \"whitenoise.storage.CompressedManifestStaticFilesStorage\"\n\n# Use DATABASE_URL in production\nDATABASE_URL = os.getenv(\"DATABASE_URL\")\n\nif DATABASE_URL is not None:\n    DATABASES = {\"default\": DATABASE_URL}\nelse:\n    # Default to sqlite for simplicity in development\n    DATABASES = {\n        \"default\": {\n            \"ENGINE\": \"django.db.backends.sqlite3\",\n            \"NAME\": BASE_DIR + \"/\" + \"db.sqlite3\",\n        }\n    }\n\n# Email Backend Setup\nif \"EMAIL_HOST\" not in os.environ:\n    EMAIL_BACKEND = \"django.core.mail.backends.console.EmailBackend\"\n    EMAIL_HOST_USER = \"test@civiwiki.org\"\nelse:\n    EMAIL_BACKEND = \"django.core.mail.backends.smtp.EmailBackend\"\n    EMAIL_HOST = os.getenv(\"EMAIL_HOST\")\n    EMAIL_PORT = os.getenv(\"EMAIL_PORT\")\n    EMAIL_HOST_USER = os.getenv(\"EMAIL_HOST_USER\")\n    EMAIL_HOST_PASSWORD = os.getenv(\"EMAIL_HOST_PASSWORD\")\n    EMAIL_USE_SSL = True\n    DEFAULT_FROM_EMAIL = EMAIL_HOST\n\n# Notification API Settings\nNOTIFICATIONS_SOFT_DELETE = True\nNOTIFICATIONS_USE_JSONFIELD = True\n\n# Django REST API Settings\nDEFAULT_RENDERER_CLASSES = (\"rest_framework.renderers.JSONRenderer\",)\n\nDEFAULT_AUTHENTICATION_CLASSES = (\"rest_framework.authentication.BasicAuthentication\",)\n\nif DEBUG:\n    # Browsable HTML - Enabled only in Debug mode (dev)\n    DEFAULT_RENDERER_CLASSES = DEFAULT_RENDERER_CLASSES + (\n        \"rest_framework.renderers.BrowsableAPIRenderer\",\n    )\n\n    DEFAULT_AUTHENTICATION_CLASSES = (\n        \"api.authentication.CsrfExemptSessionAuthentication\",\n    ) + DEFAULT_AUTHENTICATION_CLASSES\n\nREST_FRAMEWORK = {\n    \"DEFAULT_PERMISSION_CLASSES\": (\"rest_framework.permissions.IsAuthenticated\",),\n    \"DEFAULT_RENDERER_CLASSES\": DEFAULT_RENDERER_CLASSES,\n    \"DEFAULT_AUTHENTICATION_CLASSES\": DEFAULT_AUTHENTICATION_CLASSES,\n}\n\n# CORS Settings\nCORS_ORIGIN_ALLOW_ALL = True\n\n# Custom User model\nAUTH_USER_MODEL = 'accounts.User'\n\nAPPEND_SLASH = False\n\nDEFAULT_AUTO_FIELD = 'django.db.models.AutoField'\n\nLOGIN_REDIRECT_URL = '/'\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',\n        'OPTIONS': {\n            'min_length': 8,\n        }\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',\n    },\n]\n", "path": "project/core/settings.py"}], "after_files": [{"content": "\"\"\"\nDjango settings for civiwiki project.\nDarius Calliet May 12, 2016\n\nProduction settings file to select proper environment variables.\n\"\"\"\nimport os\n\n# False if not in os.environ\nDEBUG = os.getenv(\"DEBUG\", False)\n\n# defaults to second value if not found in os.environ\nDJANGO_HOST = os.getenv(\"DJANGO_HOST\", \"LOCALHOST\")\n\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\nSECRET_KEY = os.getenv(\"DJANGO_SECRET_KEY\", \"TEST_KEY_FOR_DEVELOPMENT\")\nALLOWED_HOSTS = [\".herokuapp.com\", \".civiwiki.org\", \"127.0.0.1\", \"localhost\", \"0.0.0.0\"]\n\nINSTALLED_APPS = (\n    \"django.contrib.admin\",\n    \"django.contrib.auth\",\n    \"django.contrib.contenttypes\",\n    \"django.contrib.sessions\",\n    \"django.contrib.messages\",\n    \"django.contrib.staticfiles\",\n    \"django_extensions\",\n    \"storages\",\n    \"core\",  # TODO: consider removing this, if we can move the decorators, etc. to an actual app\n    \"api\",\n    \"rest_framework\",\n    \"accounts\",\n    \"threads\",\n    \"frontend_views\",\n    \"notifications\",\n    \"corsheaders\",\n    \"taggit\",\n)\n\nMIDDLEWARE = [\n    \"corsheaders.middleware.CorsMiddleware\",\n    \"django.middleware.security.SecurityMiddleware\",\n    \"whitenoise.middleware.WhiteNoiseMiddleware\",\n    \"django.contrib.sessions.middleware.SessionMiddleware\",\n    \"django.middleware.common.CommonMiddleware\",\n    \"django.middleware.csrf.CsrfViewMiddleware\",\n    \"django.contrib.auth.middleware.AuthenticationMiddleware\",\n    # 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',\n    \"django.contrib.messages.middleware.MessageMiddleware\",\n    \"django.middleware.clickjacking.XFrameOptionsMiddleware\",\n]\n\nCSRF_USE_SESSIONS = (\n    True  # Store the CSRF token in the users session instead of in a cookie\n)\n\nCORS_ORIGIN_ALLOW_ALL = True\nROOT_URLCONF = \"core.urls\"\nLOGIN_URL = \"/login\"\n\n# SSL Setup\nif DJANGO_HOST != \"LOCALHOST\":\n    SECURE_PROXY_SSL_HEADER = (\"HTTP_X_FORWARDED_PROTO\", \"https\")\n    SECURE_SSL_REDIRECT = True\n    SESSION_COOKIE_SECURE = True\n    CSRF_COOKIE_SECURE = True\n\n# Internationalization & Localization\nLANGUAGE_CODE = \"en-us\"\nTIME_ZONE = \"UTC\"\nUSE_I18N = True\nUSE_L10N = True\nUSE_TZ = True\n\nTEMPLATES = [\n    {\n        \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n        \"DIRS\": [\n            os.path.join(BASE_DIR, \"threads/templates/threads\"), os.path.join(BASE_DIR, \"accounts/templates/accounts\")\n        ],  # TODO: Add non-webapp template directory\n        \"APP_DIRS\": True,\n        \"OPTIONS\": {\n            \"context_processors\": [\n                \"django.template.context_processors.debug\",\n                \"django.template.context_processors.request\",\n                \"django.contrib.auth.context_processors.auth\",\n                \"django.contrib.messages.context_processors.messages\",\n            ],\n        },\n    },\n]\n\nWSGI_APPLICATION = \"core.wsgi.application\"\n\n# Apex Contact for Production Errors\nADMINS = [(\"Development Team\", \"dev@civiwiki.org\")]\n\n# AWS S3 Setup\nif \"AWS_STORAGE_BUCKET_NAME\" not in os.environ:\n    MEDIA_URL = \"/media/\"\n    MEDIA_ROOT = os.path.join(BASE_DIR, \"media\")\nelse:\n    AWS_STORAGE_BUCKET_NAME = os.getenv(\"AWS_STORAGE_BUCKET_NAME\")\n    AWS_S3_ACCESS_KEY_ID = os.getenv(\"AWS_S3_ACCESS_KEY_ID\")\n    AWS_S3_SECRET_ACCESS_KEY = os.getenv(\"AWS_S3_SECRET_ACCESS_KEY\")\n    DEFAULT_FILE_STORAGE = \"storages.backends.s3boto.S3BotoStorage\"\n    AWS_S3_SECURE_URLS = False\n    AWS_QUERYSTRING_AUTH = False\n\nSTATIC_URL = \"/static/\"\nSTATICFILES_DIRS = (os.path.join(BASE_DIR, \"threads/templates/static\"),)\nSTATIC_ROOT = os.path.join(BASE_DIR, \"staticfiles\")\n\n# TODO: re-organize and simplify staticfiles settings\nif \"CIVIWIKI_LOCAL_NAME\" not in os.environ:\n    STATICFILES_STORAGE = \"whitenoise.storage.CompressedManifestStaticFilesStorage\"\n\n# Use DATABASE_URL in production\nDATABASE_URL = os.getenv(\"DATABASE_URL\")\n\nif DATABASE_URL is not None:\n    DATABASES = {\"default\": DATABASE_URL}\nelse:\n    # Default to sqlite for simplicity in development\n    DATABASES = {\n        \"default\": {\n            \"ENGINE\": \"django.db.backends.sqlite3\",\n            \"NAME\": BASE_DIR + \"/\" + \"db.sqlite3\",\n        }\n    }\n\n# Email Backend Setup\nif \"EMAIL_HOST\" not in os.environ:\n    EMAIL_BACKEND = \"django.core.mail.backends.console.EmailBackend\"\n    EMAIL_HOST_USER = \"test@civiwiki.org\"\nelse:\n    EMAIL_BACKEND = \"django.core.mail.backends.smtp.EmailBackend\"\n    EMAIL_HOST = os.getenv(\"EMAIL_HOST\")\n    EMAIL_PORT = os.getenv(\"EMAIL_PORT\")\n    EMAIL_HOST_USER = os.getenv(\"EMAIL_HOST_USER\")\n    EMAIL_HOST_PASSWORD = os.getenv(\"EMAIL_HOST_PASSWORD\")\n    EMAIL_USE_SSL = True\n    DEFAULT_FROM_EMAIL = EMAIL_HOST\n\n# Notification API Settings\nNOTIFICATIONS_SOFT_DELETE = True\nNOTIFICATIONS_USE_JSONFIELD = True\n\n# Django REST API Settings\nDEFAULT_RENDERER_CLASSES = (\"rest_framework.renderers.JSONRenderer\",)\n\nDEFAULT_AUTHENTICATION_CLASSES = (\"rest_framework.authentication.SessionAuthentication\",)\n\nif DEBUG:\n    # Browsable HTML - Enabled only in Debug mode (dev)\n    DEFAULT_RENDERER_CLASSES = DEFAULT_RENDERER_CLASSES + (\n        \"rest_framework.renderers.BrowsableAPIRenderer\",\n    )\n\n    DEFAULT_AUTHENTICATION_CLASSES = (\n        \"api.authentication.CsrfExemptSessionAuthentication\",\n    ) + DEFAULT_AUTHENTICATION_CLASSES\n\nREST_FRAMEWORK = {\n    \"DEFAULT_PERMISSION_CLASSES\": (\"rest_framework.permissions.IsAuthenticated\",),\n    \"DEFAULT_RENDERER_CLASSES\": DEFAULT_RENDERER_CLASSES,\n    \"DEFAULT_AUTHENTICATION_CLASSES\": DEFAULT_AUTHENTICATION_CLASSES,\n}\n\n# CORS Settings\nCORS_ORIGIN_ALLOW_ALL = True\n\n# Custom User model\nAUTH_USER_MODEL = 'accounts.User'\n\nAPPEND_SLASH = False\n\nDEFAULT_AUTO_FIELD = 'django.db.models.AutoField'\n\nLOGIN_REDIRECT_URL = '/'\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',\n        'OPTIONS': {\n            'min_length': 8,\n        }\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',\n    },\n]\n", "path": "project/core/settings.py"}]}