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
|
# Heading
|
||||||
|
|
||||||
My content
|
My content
|
||||||
|
|
||||||
|
You're on page {{ request.path }}
|
||||||
|
|
|
@ -2,3 +2,4 @@ django
|
||||||
git+https://github.com/andrewgodwin/yamdl@8d34d7397f3564a550042e81ea79cca7d2f3777e
|
git+https://github.com/andrewgodwin/yamdl@8d34d7397f3564a550042e81ea79cca7d2f3777e
|
||||||
gunicorn
|
gunicorn
|
||||||
markdown
|
markdown
|
||||||
|
chrono
|
||||||
|
|
|
@ -2,7 +2,7 @@ from .models import Page
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.db import connections
|
from django.db import connections
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.template import Template, Context
|
||||||
|
|
||||||
def search(request):
|
def search(request):
|
||||||
with connections["default"].cursor() as cursor:
|
with connections["default"].cursor() as cursor:
|
||||||
|
@ -15,4 +15,6 @@ def search(request):
|
||||||
def content(request, slug):
|
def content(request, slug):
|
||||||
page = get_object_or_404(Page, slug=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