1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
theorangeone.net-legacy/project/blog/views.py

20 lines
604 B
Python
Raw Normal View History

2016-02-20 19:27:18 +00:00
from project.common.views import CustomTemplate
from .utils import get_post
from django.http import Http404
class BlogView(CustomTemplate):
template_name="blog/posts.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['blog'] = self.blog_data
return context
def dispatch(self, request, *args, **kwargs):
self.blog_data = get_post(kwargs['slug'])
if not self.blog_data:
raise Http404
self.html_title = self.blog_data['title']
return super().dispatch(request, *args, **kwargs)