|
@@ -1,9 +1,23 @@
|
|
|
-from django.shortcuts import render
|
|
|
+# from django.shortcuts import render
|
|
|
+from django.shortcuts import render, get_object_or_404
|
|
|
# from django.http import HttpResponse
|
|
|
|
|
|
+from . models import Page
|
|
|
+
|
|
|
# Create your views here.
|
|
|
|
|
|
-def index(request):
|
|
|
+def index(request, pagename):
|
|
|
# return HttpResponse("<h1>The Homepage</h1>")
|
|
|
- return render(request, 'pages/page.html') # "base.html" )
|
|
|
+ # return render(request, 'pages/page.html') # "base.html" )
|
|
|
+ pagename = '/' + pagename
|
|
|
+ # pg = Page.objects.get(permalink=pagename)
|
|
|
+ pg = get_object_or_404(Page, permalink=pagename)
|
|
|
+ context = {
|
|
|
+ 'title': pg.title,
|
|
|
+ 'content': pg.bodytext,
|
|
|
+ 'last_updated': pg.update_date,
|
|
|
+ 'page_list': Page.objects.all(),
|
|
|
+ }
|
|
|
+ # assert False # django debug page is cool!
|
|
|
+ return render(request, 'pages/page.html', context)
|
|
|
|