File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,8 +23,12 @@ def add_video_like_post(request, pk):
2323
2424
2525def 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 ()
168173def 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 )
You can’t perform that action at this time.
0 commit comments