forked from gnyylmz/BlogProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
173 lines (151 loc) · 5.58 KB
/
views.py
File metadata and controls
173 lines (151 loc) · 5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
from django.shortcuts import render,get_list_or_404
from Blog.models import post, category
from django.core.paginator import Paginator,EmptyPage
from django.http import Http404
from BlogProject.settings import web_site_name,web_site_slogan,web_site_url
# Create your views here.
def home(request):
"""Ana Sayfa"""
db = post.objects.filter(is_active=True).order_by('?')[:6]
last_db = post.objects.filter(is_active=True).order_by('-time')[:3]
return render(request, 'home.html', {
'db': db,
'last_db':last_db,
'web_site_name': web_site_name,
'web_site_slogan': web_site_slogan
})
def about(request):
""" Hakkımda Sayfası """
last_db = post.objects.filter(is_active=True).order_by('-time')[:3]
return render(request, 'about.html', {
'last_db': last_db,
'web_site_name':web_site_name,
'web_site_slogan':web_site_slogan,
})
def contact(request):
""" İletişim Sayfası """
last_db = post.objects.filter(is_active=True).order_by('-time')[:3]
return render(request, 'contact.html', {
'last_db': last_db,
'web_site_name': web_site_name,
'web_site_slogan': web_site_slogan
})
def blog(request):
""" Blog yazıların listelendiği sayfa"""
last_db = post.objects.filter(is_active=True).order_by('-time')[:3]
db = post.objects.filter(is_active=True).order_by('-time')[:6]
post_db = post.objects.filter(is_active=True)
category_db = category.objects.all()
pages = Paginator(post_db,5)
return render(request, 'blog.html', {
'last_db': last_db,
'db': db,
'pages': pages,
'category_db': category_db,
'web_site_name': web_site_name,
'web_site_slogan': web_site_slogan,
})
def page(request,id):
""" Blog Sayfalaması """
last_db = post.objects.filter(is_active=True).order_by('-time')[:3]
post_db = post.objects.filter(is_active=True).order_by('-time')
category_db = category.objects.all()
pages = Paginator(post_db,5)
try:
db = pages.page(id)
except EmptyPage:
raise Http404()
return render(request, 'page.html', {
'last_db': last_db,
'db': db,
'pages': pages,
'category_db': category_db,
'web_site_name': web_site_name,
'web_site_slogan': web_site_slogan
})
def blog_details(request, slug):
""" makale_details sayfası """
last_db = post.objects.filter(is_active=True).order_by('-time')[:3]
category_db = category.objects.all()
db = post.objects.filter(seo_url=slug,is_active=True)
for seo_info in db:
title = seo_info.title
description = seo_info.description
keywords = seo_info.keywords
image = seo_info.image
return render(request, 'blog_details.html', {
'last_db': last_db,
'db': get_list_or_404(db),
'category_db': category_db,
'web_site_name': web_site_name,
'web_site_slogan': web_site_slogan,
'web_site_url':web_site_url,
'title':title,
'description':description,
'keywords':keywords,
'image':image
})
def category_view(request, category_names):
""" category details sayfası """
last_db = post.objects.filter(is_active=True).order_by('-time')[:3]
category_db_list = category.objects.all()
category_db = category.objects.filter(seo_url=category_names)
post_db = post.objects.filter(category_list__seo_url=category_names,is_active=True).order_by('-time')
pages = Paginator(post_db,5)
for seo_info in category_db:
title = seo_info.category_name
description = seo_info.category_description
keywords = seo_info.category_keywords
return render(request, 'category.html', {
'last_db': last_db,
'category_db_list': category_db_list,
'category_db': category_db,
'post_db': get_list_or_404(post_db),
'pages':pages,
'category_names':category_names,
'title': title,
'description': description,
'keywords': keywords,
'web_site_name': web_site_name,
'web_site_slogan': web_site_slogan
})
def category_page(request, category_names,id):
""" category details sayfası """
last_db = post.objects.filter(is_active=True).order_by('-time')[:3]
category_db_list = category.objects.all()
category_db = category.objects.filter(seo_url=category_names)
post_db = post.objects.filter(category_list__seo_url=category_names,is_active=True).order_by('-time')
pages = Paginator(post_db,5)
for seo_info in category_db:
title = seo_info.category_name
description = seo_info.category_description
keywords = seo_info.category_keywords
try:
db = pages.page(id)
except EmptyPage:
raise Http404()
return render(request, 'category_page.html', {
'last_db': last_db,
'category_db_list': category_db_list,
'category_db': category_db,
'post_db': db,
'pages':pages,
'category_names':category_names,
'title': title,
'description': description,
'keywords': keywords,
'web_site_name': web_site_name,
'web_site_slogan': web_site_slogan
})
def human(request):
""" humans.txt"""
return render(request, 'blog_templates/humans.html')
def robots(request):
"""robots.txt"""
return render(request, 'blog_templates/robots.html')
def last_content(request):
""" Alt taraf son yazılar """
last_db = post.objects.filter(is_active=True).order_by('-time')[:3]
return render(request,'blog_templates/last_content.html',{
'last_db':last_db
})