views.py 735 B

1234567891011121314151617181920212223
  1. # from django.shortcuts import render
  2. from django.shortcuts import render, get_object_or_404
  3. # from django.http import HttpResponse
  4. from . models import Page
  5. # Create your views here.
  6. def index(request, pagename):
  7. # return HttpResponse("<h1>The Homepage</h1>")
  8. # return render(request, 'pages/page.html') # "base.html" )
  9. pagename = '/' + pagename
  10. # pg = Page.objects.get(permalink=pagename)
  11. pg = get_object_or_404(Page, permalink=pagename)
  12. context = {
  13. 'title': pg.title,
  14. 'content': pg.bodytext,
  15. 'last_updated': pg.update_date,
  16. 'page_list': Page.objects.all(),
  17. }
  18. # assert False # django debug page is cool!
  19. return render(request, 'pages/page.html', context)