diff --git a/yamdl_playground/core/templates/content.html b/yamdl_playground/core/templates/content.html new file mode 100644 index 0000000..3bf664b --- /dev/null +++ b/yamdl_playground/core/templates/content.html @@ -0,0 +1,6 @@ + + {{ page.title }} + + + {{ content }} + diff --git a/yamdl_playground/core/utils.py b/yamdl_playground/core/utils.py index 7395799..dd83c67 100644 --- a/yamdl_playground/core/utils.py +++ b/yamdl_playground/core/utils.py @@ -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 diff --git a/yamdl_playground/core/views.py b/yamdl_playground/core/views.py index 2fb532f..238c736 100644 --- a/yamdl_playground/core/views.py +++ b/yamdl_playground/core/views.py @@ -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})) + }) diff --git a/yamdl_playground/settings.py b/yamdl_playground/settings.py index ac7f2da..3c4a98d 100644 --- a/yamdl_playground/settings.py +++ b/yamdl_playground/settings.py @@ -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" +} diff --git a/yamdl_playground/urls.py b/yamdl_playground/urls.py index 9e56f8e..5808ffa 100644 --- a/yamdl_playground/urls.py +++ b/yamdl_playground/urls.py @@ -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//", views.content) + path("content//", views.content), + path("__debug__/", include("debug_toolbar.urls")), ]