Install DDT
This commit is contained in:
parent
10baac9617
commit
7475d70c95
5 changed files with 24 additions and 6 deletions
6
yamdl_playground/core/templates/content.html
Normal file
6
yamdl_playground/core/templates/content.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<head>
|
||||
<title>{{ page.title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
{{ content }}
|
||||
</body>
|
|
@ -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
|
||||
|
|
|
@ -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}))
|
||||
})
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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")),
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue