We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
add django-debug-toolbar
## Task

- [ ] install `django-debug-toolbar` with the command `poetry add django-debug-toolbar --group dev`
- [ ] follow the [remaining installation instructions](https://django-debug-toolbar.readthedocs.io/en/latest/installation.html)

--- 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/urls.py`
Content:
```
1 """civiwiki URL Configuration
2 
3 The `urlpatterns` list routes URLs to views. For more information please see:
4     https://docs.djangoproject.com/en/3.2/topics/http/urls/
5 Examples:
6 Function views
7     1. Add an import:  from my_app import views
8     2. Add a URL to urlpatterns:  path('', views.home, name='home')
9 Class-based views
10     1. Add an import:  from other_app.views import Home
11     2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
12 Including another URLconf
13     1. Import the include() function: from django.urls import include, path
14     2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
15 """
16 
17 from django.conf import settings
18 from django.conf.urls.static import static
19 from django.contrib import admin
20 from django.urls import include, path, re_path
21 from django.views.generic.base import RedirectView
22 from django.views.static import serve
23 
24 from core.router import CiviWikiRouter
25 
26 
27 urlpatterns = [
28     path("admin/", admin.site.urls),
29     path("api/v1/", include(CiviWikiRouter.urls)),
30     path("api/", include("accounts.urls.api")),
31     path("api/", include("threads.urls.api")),
32     path("", include("accounts.urls.urls")),
33     path("", include("threads.urls.urls")),
34     path(
35         "inbox/notifications/",
36         include("notifications.urls", namespace="notifications"),
37     ),
38     path("favicon.ico", RedirectView.as_view(url="/static/favicon/favicon.ico")),
39     path(
40         "favicon-32x32.png",
41         RedirectView.as_view(url="/static/favicon/favicon-32x32.png"),
42     ),
43     path(
44         "apple-touch-icon.png",
45         RedirectView.as_view(url="/static/favicon/apple-touch-icon.png"),
46     ),
47     path(
48         "mstile-144x144.png",
49         RedirectView.as_view(url="/static/favicon/mstile-144x144.png"),
50     ),
51     re_path(r"^media/(?P<path>.*)$", serve, {"document_root": settings.MEDIA_ROOT}),
52 ]
53 
54 urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
55 urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
56
```

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",
29     "rest_framework",
30     "accounts.apps.AccountsConfig",
31     "threads",
32     "notifications",
33     "corsheaders",
34     "taggit",
35     "categories",
36     "notification",
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 
59 # SSL Setup
60 if DJANGO_HOST != "LOCALHOST":
61     SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
62     SECURE_SSL_REDIRECT = True
63     SESSION_COOKIE_SECURE = True
64     CSRF_COOKIE_SECURE = True
65 
66 # Internationalization & Localization
67 LANGUAGE_CODE = "en-us"
68 TIME_ZONE = "UTC"
69 USE_I18N = True
70 USE_L10N = True
71 USE_TZ = True
72 
73 TEMPLATES = [
74     {
75         "BACKEND": "django.template.backends.django.DjangoTemplates",
76         "DIRS": [
77             os.path.join(BASE_DIR, "threads/templates/threads"),
78             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 STATIC_URL = "/static/"
98 STATICFILES_DIRS = (os.path.join(BASE_DIR, "core/templates/static"),)
99 STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
100 
101 MEDIA_ROOT = os.path.join(BASE_DIR, "media")
102 MEDIA_URL = "/media/"
103 
104 # TODO: re-organize and simplify staticfiles settings
105 if "CIVIWIKI_LOCAL_NAME" not in os.environ:
106     STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
107 
108 # Use DATABASE_URL in production
109 DATABASE_URL = os.getenv("DATABASE_URL")
110 
111 if DATABASE_URL is not None:
112     DATABASES = {"default": DATABASE_URL}
113 else:
114     # Default to sqlite for simplicity in development
115     DATABASES = {
116         "default": {
117             "ENGINE": "django.db.backends.sqlite3",
118             "NAME": BASE_DIR + "/" + "db.sqlite3",
119         }
120     }
121 
122 # Email Backend Setup
123 if "EMAIL_HOST" not in os.environ:
124     EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
125     EMAIL_HOST_USER = "test@civiwiki.org"
126 else:
127     EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
128     EMAIL_HOST = os.getenv("EMAIL_HOST")
129     EMAIL_PORT = os.getenv("EMAIL_PORT")
130     EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
131     EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
132     EMAIL_USE_SSL = True
133     DEFAULT_FROM_EMAIL = EMAIL_HOST
134 
135 # Notification API Settings
136 NOTIFICATIONS_SOFT_DELETE = True
137 NOTIFICATIONS_USE_JSONFIELD = True
138 
139 # Django REST API Settings
140 DEFAULT_RENDERER_CLASSES = ("rest_framework.renderers.JSONRenderer",)
141 
142 if DEBUG:
143     # Browsable HTML - Enabled only in Debug mode (dev)
144     DEFAULT_RENDERER_CLASSES = DEFAULT_RENDERER_CLASSES + (
145         "rest_framework.renderers.BrowsableAPIRenderer",
146     )
147 
148 REST_FRAMEWORK = {
149     "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
150     "DEFAULT_RENDERER_CLASSES": DEFAULT_RENDERER_CLASSES,
151     "DEFAULT_AUTHENTICATION_CLASSES": (
152         "rest_framework.authentication.BasicAuthentication",
153         "rest_framework.authentication.SessionAuthentication",
154     ),
155 }
156 
157 # CORS Settings
158 CORS_ORIGIN_ALLOW_ALL = True
159 
160 # Custom User model
161 AUTH_USER_MODEL = "accounts.User"
162 
163 DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
164 
165 # Login Logout URLS
166 LOGIN_URL = "login/"
167 LOGIN_REDIRECT_URL = "/"
168 LOGOUT_REDIRECT_URL = "/"
169 
170 AUTH_PASSWORD_VALIDATORS = [
171     {
172         "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",  # noqa: E501
173     },
174     {
175         "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
176         "OPTIONS": {
177             "min_length": 4,
178         },
179     },
180     {
181         "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
182     },
183     {
184         "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
185     },
186 ]
187 
188 LOGGING = {
189     "version": 1,
190     "disable_existing_loggers": False,
191     "formatters": {"rich": {"datefmt": "[%X]"}},
192     "handlers": {
193         "console": {
194             "class": "rich.logging.RichHandler",
195             "formatter": "rich",
196             "level": "WARNING",
197             # "filters": ["require_debug_true"],
198             "rich_tracebacks": True,
199             "tracebacks_show_locals": True,
200         }
201     },
202     "loggers": {"django": {"handlers": ["console"]}},
203 }
204
```
--- 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
@@ -34,9 +34,11 @@
     "taggit",
     "categories",
     "notification",
+    "debug_toolbar",
 )
 
 MIDDLEWARE = [
+    "debug_toolbar.middleware.DebugToolbarMiddleware",
     "corsheaders.middleware.CorsMiddleware",
     "django.middleware.security.SecurityMiddleware",
     "whitenoise.middleware.WhiteNoiseMiddleware",
@@ -49,6 +51,10 @@
     "django.middleware.clickjacking.XFrameOptionsMiddleware",
 ]
 
+INTERNAL_IPS = [
+    "127.0.0.1",
+]
+
 CSRF_USE_SESSIONS = (
     True  # Store the CSRF token in the users session instead of in a cookie
 )
diff --git a/project/core/urls.py b/project/core/urls.py
--- a/project/core/urls.py
+++ b/project/core/urls.py
@@ -49,6 +49,7 @@
         RedirectView.as_view(url="/static/favicon/mstile-144x144.png"),
     ),
     re_path(r"^media/(?P<path>.*)$", serve, {"document_root": settings.MEDIA_ROOT}),
+    path("__debug__/", include("debug_toolbar.urls")),
 ]
 
 urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

{"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@@ -34,9 +34,11 @@\n     \"taggit\",\n     \"categories\",\n     \"notification\",\n+    \"debug_toolbar\",\n )\n \n MIDDLEWARE = [\n+    \"debug_toolbar.middleware.DebugToolbarMiddleware\",\n     \"corsheaders.middleware.CorsMiddleware\",\n     \"django.middleware.security.SecurityMiddleware\",\n     \"whitenoise.middleware.WhiteNoiseMiddleware\",\n@@ -49,6 +51,10 @@\n     \"django.middleware.clickjacking.XFrameOptionsMiddleware\",\n ]\n \n+INTERNAL_IPS = [\n+    \"127.0.0.1\",\n+]\n+\n CSRF_USE_SESSIONS = (\n     True  # Store the CSRF token in the users session instead of in a cookie\n )\ndiff --git a/project/core/urls.py b/project/core/urls.py\n--- a/project/core/urls.py\n+++ b/project/core/urls.py\n@@ -49,6 +49,7 @@\n         RedirectView.as_view(url=\"/static/favicon/mstile-144x144.png\"),\n     ),\n     re_path(r\"^media/(?P<path>.*)$\", serve, {\"document_root\": settings.MEDIA_ROOT}),\n+    path(\"__debug__/\", include(\"debug_toolbar.urls\")),\n ]\n \n urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)\n", "issue": "add django-debug-toolbar\n## Task\r\n\r\n- [ ] install `django-debug-toolbar` with the command `poetry add django-debug-toolbar --group dev`\r\n- [ ] follow the [remaining installation instructions](https://django-debug-toolbar.readthedocs.io/en/latest/installation.html)\n", "before_files": [{"content": "\"\"\"civiwiki URL Configuration\n\nThe `urlpatterns` list routes URLs to views. For more information please see:\n    https://docs.djangoproject.com/en/3.2/topics/http/urls/\nExamples:\nFunction views\n    1. Add an import:  from my_app import views\n    2. Add a URL to urlpatterns:  path('', views.home, name='home')\nClass-based views\n    1. Add an import:  from other_app.views import Home\n    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')\nIncluding another URLconf\n    1. Import the include() function: from django.urls import include, path\n    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))\n\"\"\"\n\nfrom django.conf import settings\nfrom django.conf.urls.static import static\nfrom django.contrib import admin\nfrom django.urls import include, path, re_path\nfrom django.views.generic.base import RedirectView\nfrom django.views.static import serve\n\nfrom core.router import CiviWikiRouter\n\n\nurlpatterns = [\n    path(\"admin/\", admin.site.urls),\n    path(\"api/v1/\", include(CiviWikiRouter.urls)),\n    path(\"api/\", include(\"accounts.urls.api\")),\n    path(\"api/\", include(\"threads.urls.api\")),\n    path(\"\", include(\"accounts.urls.urls\")),\n    path(\"\", include(\"threads.urls.urls\")),\n    path(\n        \"inbox/notifications/\",\n        include(\"notifications.urls\", namespace=\"notifications\"),\n    ),\n    path(\"favicon.ico\", RedirectView.as_view(url=\"/static/favicon/favicon.ico\")),\n    path(\n        \"favicon-32x32.png\",\n        RedirectView.as_view(url=\"/static/favicon/favicon-32x32.png\"),\n    ),\n    path(\n        \"apple-touch-icon.png\",\n        RedirectView.as_view(url=\"/static/favicon/apple-touch-icon.png\"),\n    ),\n    path(\n        \"mstile-144x144.png\",\n        RedirectView.as_view(url=\"/static/favicon/mstile-144x144.png\"),\n    ),\n    re_path(r\"^media/(?P<path>.*)$\", serve, {\"document_root\": settings.MEDIA_ROOT}),\n]\n\nurlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)\nurlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n", "path": "project/core/urls.py"}, {"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\",\n    \"rest_framework\",\n    \"accounts.apps.AccountsConfig\",\n    \"threads\",\n    \"notifications\",\n    \"corsheaders\",\n    \"taggit\",\n    \"categories\",\n    \"notification\",\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\"\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\"),\n            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\nSTATIC_URL = \"/static/\"\nSTATICFILES_DIRS = (os.path.join(BASE_DIR, \"core/templates/static\"),)\nSTATIC_ROOT = os.path.join(BASE_DIR, \"staticfiles\")\n\nMEDIA_ROOT = os.path.join(BASE_DIR, \"media\")\nMEDIA_URL = \"/media/\"\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\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\nREST_FRAMEWORK = {\n    \"DEFAULT_PERMISSION_CLASSES\": (\"rest_framework.permissions.IsAuthenticated\",),\n    \"DEFAULT_RENDERER_CLASSES\": DEFAULT_RENDERER_CLASSES,\n    \"DEFAULT_AUTHENTICATION_CLASSES\": (\n        \"rest_framework.authentication.BasicAuthentication\",\n        \"rest_framework.authentication.SessionAuthentication\",\n    ),\n}\n\n# CORS Settings\nCORS_ORIGIN_ALLOW_ALL = True\n\n# Custom User model\nAUTH_USER_MODEL = \"accounts.User\"\n\nDEFAULT_AUTO_FIELD = \"django.db.models.AutoField\"\n\n# Login Logout URLS\nLOGIN_URL = \"login/\"\nLOGIN_REDIRECT_URL = \"/\"\nLOGOUT_REDIRECT_URL = \"/\"\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.UserAttributeSimilarityValidator\",  # noqa: E501\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.MinimumLengthValidator\",\n        \"OPTIONS\": {\n            \"min_length\": 4,\n        },\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.CommonPasswordValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.NumericPasswordValidator\",\n    },\n]\n\nLOGGING = {\n    \"version\": 1,\n    \"disable_existing_loggers\": False,\n    \"formatters\": {\"rich\": {\"datefmt\": \"[%X]\"}},\n    \"handlers\": {\n        \"console\": {\n            \"class\": \"rich.logging.RichHandler\",\n            \"formatter\": \"rich\",\n            \"level\": \"WARNING\",\n            # \"filters\": [\"require_debug_true\"],\n            \"rich_tracebacks\": True,\n            \"tracebacks_show_locals\": True,\n        }\n    },\n    \"loggers\": {\"django\": {\"handlers\": [\"console\"]}},\n}\n", "path": "project/core/settings.py"}], "after_files": [{"content": "\"\"\"civiwiki URL Configuration\n\nThe `urlpatterns` list routes URLs to views. For more information please see:\n    https://docs.djangoproject.com/en/3.2/topics/http/urls/\nExamples:\nFunction views\n    1. Add an import:  from my_app import views\n    2. Add a URL to urlpatterns:  path('', views.home, name='home')\nClass-based views\n    1. Add an import:  from other_app.views import Home\n    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')\nIncluding another URLconf\n    1. Import the include() function: from django.urls import include, path\n    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))\n\"\"\"\n\nfrom django.conf import settings\nfrom django.conf.urls.static import static\nfrom django.contrib import admin\nfrom django.urls import include, path, re_path\nfrom django.views.generic.base import RedirectView\nfrom django.views.static import serve\n\nfrom core.router import CiviWikiRouter\n\n\nurlpatterns = [\n    path(\"admin/\", admin.site.urls),\n    path(\"api/v1/\", include(CiviWikiRouter.urls)),\n    path(\"api/\", include(\"accounts.urls.api\")),\n    path(\"api/\", include(\"threads.urls.api\")),\n    path(\"\", include(\"accounts.urls.urls\")),\n    path(\"\", include(\"threads.urls.urls\")),\n    path(\n        \"inbox/notifications/\",\n        include(\"notifications.urls\", namespace=\"notifications\"),\n    ),\n    path(\"favicon.ico\", RedirectView.as_view(url=\"/static/favicon/favicon.ico\")),\n    path(\n        \"favicon-32x32.png\",\n        RedirectView.as_view(url=\"/static/favicon/favicon-32x32.png\"),\n    ),\n    path(\n        \"apple-touch-icon.png\",\n        RedirectView.as_view(url=\"/static/favicon/apple-touch-icon.png\"),\n    ),\n    path(\n        \"mstile-144x144.png\",\n        RedirectView.as_view(url=\"/static/favicon/mstile-144x144.png\"),\n    ),\n    re_path(r\"^media/(?P<path>.*)$\", serve, {\"document_root\": settings.MEDIA_ROOT}),\n    path(\"__debug__/\", include(\"debug_toolbar.urls\")),\n]\n\nurlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)\nurlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n", "path": "project/core/urls.py"}, {"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\",\n    \"rest_framework\",\n    \"accounts.apps.AccountsConfig\",\n    \"threads\",\n    \"notifications\",\n    \"corsheaders\",\n    \"taggit\",\n    \"categories\",\n    \"notification\",\n    \"debug_toolbar\",\n)\n\nMIDDLEWARE = [\n    \"debug_toolbar.middleware.DebugToolbarMiddleware\",\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\nINTERNAL_IPS = [\n    \"127.0.0.1\",\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\"\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\"),\n            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\nSTATIC_URL = \"/static/\"\nSTATICFILES_DIRS = (os.path.join(BASE_DIR, \"core/templates/static\"),)\nSTATIC_ROOT = os.path.join(BASE_DIR, \"staticfiles\")\n\nMEDIA_ROOT = os.path.join(BASE_DIR, \"media\")\nMEDIA_URL = \"/media/\"\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\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\nREST_FRAMEWORK = {\n    \"DEFAULT_PERMISSION_CLASSES\": (\"rest_framework.permissions.IsAuthenticated\",),\n    \"DEFAULT_RENDERER_CLASSES\": DEFAULT_RENDERER_CLASSES,\n    \"DEFAULT_AUTHENTICATION_CLASSES\": (\n        \"rest_framework.authentication.BasicAuthentication\",\n        \"rest_framework.authentication.SessionAuthentication\",\n    ),\n}\n\n# CORS Settings\nCORS_ORIGIN_ALLOW_ALL = True\n\n# Custom User model\nAUTH_USER_MODEL = \"accounts.User\"\n\nDEFAULT_AUTO_FIELD = \"django.db.models.AutoField\"\n\n# Login Logout URLS\nLOGIN_URL = \"login/\"\nLOGIN_REDIRECT_URL = \"/\"\nLOGOUT_REDIRECT_URL = \"/\"\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.UserAttributeSimilarityValidator\",  # noqa: E501\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.MinimumLengthValidator\",\n        \"OPTIONS\": {\n            \"min_length\": 4,\n        },\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.CommonPasswordValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.NumericPasswordValidator\",\n    },\n]\n\nLOGGING = {\n    \"version\": 1,\n    \"disable_existing_loggers\": False,\n    \"formatters\": {\"rich\": {\"datefmt\": \"[%X]\"}},\n    \"handlers\": {\n        \"console\": {\n            \"class\": \"rich.logging.RichHandler\",\n            \"formatter\": \"rich\",\n            \"level\": \"WARNING\",\n            # \"filters\": [\"require_debug_true\"],\n            \"rich_tracebacks\": True,\n            \"tracebacks_show_locals\": True,\n        }\n    },\n    \"loggers\": {\"django\": {\"handlers\": [\"console\"]}},\n}\n", "path": "project/core/settings.py"}]}