Render page content as template
This commit is contained in:
parent
ff90e8422b
commit
10baac9617
3 changed files with 7 additions and 2 deletions
|
@ -7,3 +7,5 @@ tags:
|
|||
# Heading
|
||||
|
||||
My content
|
||||
|
||||
You're on page {{ request.path }}
|
||||
|
|
|
@ -2,3 +2,4 @@ django
|
|||
git+https://github.com/andrewgodwin/yamdl@8d34d7397f3564a550042e81ea79cca7d2f3777e
|
||||
gunicorn
|
||||
markdown
|
||||
chrono
|
||||
|
|
|
@ -2,7 +2,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.template import Template, Context
|
||||
|
||||
def search(request):
|
||||
with connections["default"].cursor() as cursor:
|
||||
|
@ -15,4 +15,6 @@ def search(request):
|
|||
def content(request, slug):
|
||||
page = get_object_or_404(Page, slug=slug)
|
||||
|
||||
return HttpResponse(page.content, content_type="text/html")
|
||||
template = Template(page.content)
|
||||
|
||||
return HttpResponse(template.render(Context({"request": request})), content_type="text/html")
|
||||
|
|
Loading…
Reference in a new issue