]> git.sommitrealweird.co.uk Git - sommitrealweird.git/blobdiff - sommitrealweird/blog/views.py
Make sure that the css view works
[sommitrealweird.git] / sommitrealweird / blog / views.py
index 09ff5e4132e12e21a4102434aa0cd28bdac73a5d..52fab007886f526b770234b5e2897b64ed4d0bdc 100644 (file)
@@ -1,5 +1,6 @@
 from blog.models import BlogEntry, BlogSection
 from django.http import Http404, HttpResponse
 from blog.models import BlogEntry, BlogSection
 from django.http import Http404, HttpResponse
+from django.shortcuts import render
 from django.template import RequestContext, loader
 from django.core.paginator import Paginator
 from django.conf import settings
 from django.template import RequestContext, loader
 from django.core.paginator import Paginator
 from django.conf import settings
@@ -19,9 +20,7 @@ def blog_index(request, section=None):
         try:
             paginated_entries = paginator.page(page)
             pages = paginator.page_range
         try:
             paginated_entries = paginator.page(page)
             pages = paginator.page_range
-            t = loader.get_template("blog/blog_index.html")
-            c = RequestContext(request,
-                {
+            c = {
                     "entries": paginated_entries.object_list,
                     "title": settings.BLOG_TITLE,
                     "page": page,
                     "entries": paginated_entries.object_list,
                     "title": settings.BLOG_TITLE,
                     "page": page,
@@ -32,8 +31,8 @@ def blog_index(request, section=None):
                     "has_prev": paginated_entries.has_previous(),
                     "next": page + 1,
                     "prev": page - 1
                     "has_prev": paginated_entries.has_previous(),
                     "next": page + 1,
                     "prev": page - 1
-                })
-            return HttpResponse(t.render(c))
+                }
+            return render(request, 'blog/blog_index.html', c)
         except:
             raise Http404
     else:
         except:
             raise Http404
     else:
@@ -49,14 +48,11 @@ def blog_view(request, year=None, month=None, day=None, hour=None, minutes=None,
             try:
                 blog_entry = BlogEntry.objects.get(publish_date__year=year, publish_date__month=month, publish_date__day=day, slug__exact=slug)
                 template_name = "blog/single_entry_%s.html" %(blog_entry.format,)
             try:
                 blog_entry = BlogEntry.objects.get(publish_date__year=year, publish_date__month=month, publish_date__day=day, slug__exact=slug)
                 template_name = "blog/single_entry_%s.html" %(blog_entry.format,)
-                t = loader.get_template(template_name)
-                c = RequestContext(request,
-                    {
+                c = {
                         "entry": blog_entry,
                         "publish_date": blog_entry.publish_date
                     }
                         "entry": blog_entry,
                         "publish_date": blog_entry.publish_date
                     }
-                )
-                return HttpResponse(t.render(c))
+                return render(request, template_name, c)
             except:
                 raise Http404
     else:
             except:
                 raise Http404
     else:
@@ -84,9 +80,7 @@ def blog_view(request, year=None, month=None, day=None, hour=None, minutes=None,
             try:
                 paginated_entries = paginator.page(page)
                 pages = paginator.page_range
             try:
                 paginated_entries = paginator.page(page)
                 pages = paginator.page_range
-                t = loader.get_template("blog/blog_index.html")
-                c = RequestContext(request,
-                    {
+                c = {
                         "entries": paginated_entries.object_list,
                         "title": settings.BLOG_TITLE,
                         "page": page,
                         "entries": paginated_entries.object_list,
                         "title": settings.BLOG_TITLE,
                         "page": page,
@@ -97,8 +91,8 @@ def blog_view(request, year=None, month=None, day=None, hour=None, minutes=None,
                         "has_prev": paginated_entries.has_previous(),
                         "next": page + 1,
                         "prev": page - 1
                         "has_prev": paginated_entries.has_previous(),
                         "next": page + 1,
                         "prev": page - 1
-                    })
-                return HttpResponse(t.render(c))
+                    }
+                return render(request, "blog/blog_index.html", c)
             except:
                 raise Http404
         else:
             except:
                 raise Http404
         else: