featured item
This commit is contained in:
parent
490c712689
commit
2a24beb579
7 changed files with 89 additions and 10 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import random
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.conf import settings
|
||||
|
||||
|
|
@ -17,6 +18,15 @@ def index(request):
|
|||
context = {}
|
||||
context['films'] = Film.objects.filter(public=True).count()
|
||||
context['texts'] = Text.objects.filter(public=True).count()
|
||||
featured = Film.objects.filter(featured=True)
|
||||
featured_count = featured.count()
|
||||
if featured_count:
|
||||
featured = featured[random.randint(0, featured_count - 1)]
|
||||
try:
|
||||
featured = featured.data['items'][0]['id']
|
||||
except:
|
||||
featured = None
|
||||
context['featured'] = featured
|
||||
return render(request, 'index.html', context)
|
||||
|
||||
def page(request, slug=''):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue