diff --git a/blog/views.py b/blog/views.py index 0256c20..6b65f7a 100644 --- a/blog/views.py +++ b/blog/views.py @@ -2,7 +2,7 @@ from .models import Post,Category,Love,Skills,IpController,Tags from django.shortcuts import get_list_or_404 class HomeListView(ListView): - + """Ana Sayfa""" model = Post queryset = Post.objects.all().filter(is_active=True).order_by('?') context_object_name = 'post_obj' @@ -15,6 +15,7 @@ def get_context_data(self, **kwargs): return context class PostDetailView(DetailView): + """Post detay sayfası""" model = Post template_name = 'post.html' context_object_name = 'post_obj' @@ -30,11 +31,15 @@ def get_context_data(self, **kwargs): context['category'] = Category.objects.all() context['post'] = Post.objects.all().filter(is_active=True).order_by('-site_hit')[:5] - ip = IpController.objects.all().filter(remote=str(self.request.META.get('REMOTE_ADDR')),http_x=str(self.request.META.get('HTTP_X_FORWARDED_FOR')), - http_user=str(self.request.META['HTTP_USER_AGENT']),url=str(self.kwargs['slug'])) + ip = IpController.objects.all().filter(remote=str(self.request.META.get('REMOTE_ADDR')), + http_x=str(self.request.META.get('HTTP_X_FORWARDED_FOR')), + http_user=str(self.request.META['HTTP_USER_AGENT']), + url=str(self.kwargs['slug'])) if(not ip): - IpController.objects.create(remote=str(self.request.META.get('REMOTE_ADDR')),http_x=str(self.request.META.get('HTTP_X_FORWARDED_FOR')), - http_user=str(self.request.META['HTTP_USER_AGENT']),url=str(self.kwargs['slug'])).save() + IpController.objects.create(remote=str(self.request.META.get('REMOTE_ADDR')), + http_x=str(self.request.META.get('HTTP_X_FORWARDED_FOR')), + http_user=str(self.request.META['HTTP_USER_AGENT']), + url=str(self.kwargs['slug'])).save() hit = Post.objects.get(url=self.kwargs['slug']) hit.site_hit += 1 @@ -43,6 +48,7 @@ def get_context_data(self, **kwargs): return context class AboutTemplateView(TemplateView): + """Hakkımızda""" template_name = 'about.html' def get_context_data(self, **kwargs): @@ -53,6 +59,7 @@ def get_context_data(self, **kwargs): return context class BlogListView(ListView): + """Blog Listeleme""" model = Post queryset = Post.objects.all().filter(is_active=True).order_by('-time') context_object_name = 'post_obj' @@ -69,6 +76,7 @@ def get_context_data(self, **kwargs): return context class ContactView(TemplateView): + """İletişim""" template_name = 'contact.html' def get_context_data(self, **kwargs): @@ -77,26 +85,29 @@ def get_context_data(self, **kwargs): return context class CategoryView(ListView): - model = Post - template_name = 'category_page.html' - context_object_name = 'post_obj' - paginate_by = 3 - def get_queryset(self, *args, **kwargs): - return get_list_or_404(Post.objects.filter(category_list__url=self.kwargs['slug'],is_active=True)) - - def get_context_data(self, **kwargs): - context = super(CategoryView, self).get_context_data(**kwargs) - context['last_content'] = Post.objects.all().filter(is_active=True).order_by('-time') - context['category'] = Category.objects.all() - context['category_post'] = Category.objects.all().filter(url=self.kwargs['slug']) - return context + """Kategori Detay""" + model = Post + template_name = 'category_page.html' + context_object_name = 'post_obj' + paginate_by = 3 + def get_queryset(self, *args, **kwargs): + return get_list_or_404(Post.objects.filter(category_list__url=self.kwargs['slug'],is_active=True)) + + def get_context_data(self, **kwargs): + context = super(CategoryView, self).get_context_data(**kwargs) + context['last_content'] = Post.objects.all().filter(is_active=True).order_by('-time') + context['category'] = Category.objects.all() + context['category_post'] = Category.objects.all().filter(url=self.kwargs['slug']) + return context class RobotsView(TemplateView): + """robots.txt""" template_name = 'robots.html' class TagsView(ListView): + """etiket detay""" model = Tags context_object_name = 'tags_obj' template_name = 'tags.html'