def index(request):

    errors = Error.objects.all()

    # Filter by user email
    if request.GET.get('user', None):
        errors_pks = [e.error.pk for e in Event.objects.filter(logged_in_user_email=request.GET.get('user'))]
        errors = errors.filter(pk__in=errors_pks)

    errors = errors.order_by("-last_event")

    page = request.GET.get('page', 1)
    paginator = Paginator(errors, 20)
    try:
        errors = paginator.page(page)
    except PageNotAnInteger:
        errors = paginator.page(1)
    except EmptyPage:
        errors = paginator.page(paginator.num_pages)

    return render(request, "centaur/index.html", {"errors": errors})