1
Fork 0

Install DDT

This commit is contained in:
Jake Howard 2024-03-31 14:20:03 +01:00
parent 10baac9617
commit 7475d70c95
Signed by: jake
GPG key ID: 57AFB45680EDD477
5 changed files with 24 additions and 6 deletions

View file

@ -0,0 +1,6 @@
<head>
<title>{{ page.title }}</title>
</head>
<body>
{{ content }}
</body>

View file

@ -6,3 +6,7 @@ class CustomYamdlLoader(ModelLoader):
data["slug"] = file_path.stem
super().load_fixture(model_class, data, file_path)
def show_debug_toolbar(request):
return True

View file

@ -1,7 +1,7 @@
from .models import Page
from django.http import HttpResponse
from django.db import connections
from django.shortcuts import get_object_or_404
from django.shortcuts import get_object_or_404, render
from django.template import Template, Context
def search(request):
@ -17,4 +17,7 @@ def content(request, slug):
template = Template(page.content)
return HttpResponse(template.render(Context({"request": request})), content_type="text/html")
return render(request, "content.html", {
"page": page,
"content": template.render(Context({"request": request, "page": page}))
})

View file

@ -34,11 +34,13 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
"yamdl_playground.core",
"yamdl",
"debug_toolbar"
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.middleware.common.CommonMiddleware',
"debug_toolbar.middleware.DebugToolbarMiddleware",
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
@ -54,8 +56,6 @@ TEMPLATES = [
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
@ -169,3 +169,7 @@ LOGGING = {
},
},
}
DEBUG_TOOLBAR_CONFIG = {
"SHOW_TOOLBAR_CALLBACK": "yamdl_playground.core.utils.show_debug_toolbar"
}

View file

@ -14,10 +14,11 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.urls import path
from django.urls import path, include
from .core import views
urlpatterns = [
path("search/", views.search),
path("content/<slug:slug>/", views.content)
path("content/<slug:slug>/", views.content),
path("__debug__/", include("debug_toolbar.urls")),
]