Exemplo n.º 1
0
def recommendations(request, user_id):
    user =  _getuser(request)
    recommended_movies = RecommenderSystem.recommendations_for_user(user_id, 100)
    movies = _prepare_paginator(request,recommended_movies)
    return render_to_response('results.html', {
        'results_title' : 'Recommendations for %s' % user.username,
        'movies': movies,
        'user' : user
    })
Exemplo n.º 2
0
def index(request):
    user = _getuser(request)
    movies = Movie.objects.order_by('?')[:6]
    other_users = User.objects.exclude(id=user.id).order_by('?')[:3]
    other_users_movies = {}
    for other_user in other_users:
        other_users_movies[other_user.id] = Movie.objects.filter(rating__user=other_user).order_by('?')[:6]

    return render_to_response('index.html', {
        'user' : user,
        'all_movies': movies,
        'recommended_movies' : RecommenderSystem.recommendations_for_user(user.id,4),
        'other_users' : other_users,
        'other_users_movies' : other_users_movies,
        'active_other_user' : other_users[0]
    })