Skip to content

Commit db5f4d8

Browse files
committed
Deploy changes
1 parent 64724fc commit db5f4d8

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

apps/blog/views.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ def add_video_like_post(request, pk):
2323

2424

2525
def home(request):
26-
left = Post.objects.filter(active=True)[0]
27-
right = Post.objects.filter(active=True)[1]
26+
posts = Post.objects.filter(active=True)
27+
left = 0
28+
right = 0
29+
if posts.exists():
30+
left = posts[0]
31+
right = posts[1]
2832
video_posts = VideoPost.objects.all()
2933
faq = Faq.objects.filter(active=True)
3034
categories = Category.objects.all()[:5]
@@ -164,6 +168,7 @@ def contact(request):
164168
contact_form = ContactForm()
165169
return render(request, 'contact.html', {'contact_form': contact_form})
166170

171+
167172
@login_required()
168173
def write_post(request):
169174
tags = Tag.objects.all()
@@ -238,4 +243,4 @@ def user_posts(request, username):
238243
"posts": posts,
239244
"muser": user
240245
}
241-
return render(request, "user-posts.html", context)
246+
return render(request, "user-posts.html", context)

0 commit comments

Comments
 (0)