from django.shortcuts import render
from .models import Movie

def index(request):
    featured_movie = Movie.objects.filter(is_featured=True).first()
    trending_movies = Movie.objects.filter(rating__gte=8.5).order_by('-rating')
    top_rated_movies = Movie.objects.order_by('-rating')[:10]

    context = {
        'featured_movie': featured_movie,
        'trending_movies': trending_movies,
        'top_rated_movies': top_rated_movies
    }
    return render(request, 'core/index.html', context)