views.py

In [ ]:
#Decorator to force users to login URL
@login_required(login_url='/login/')
def index(request):
    skill_list = tasksx.objects.filter(creator=request.user).order_by('current')
    course_list = courses.objects.filter(creator=request.user)
    current_total = tasksx.objects.filter(creator=request.user).aggregate(Sum('current'))
    starting_total = tasksx.objects.filter(creator=request.user).aggregate(Sum('starting'))
    count = tasksx.objects.filter(creator=request.user).count()
    try:
        delta = current_total['current__sum']- starting_total['starting__sum']
    except:
        delta = '0'
    context = {'count' : count, 'skill_list' : skill_list, 'course_list' : course_list, 'starting_total' : starting_total['starting__sum'], 'current_total' : current_total['current__sum'], 'delta' : delta}

    return render(request, 'index.html', context)

HTML

In [ ]:
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <title>Dashboard - Netshock</title>
	 {% load static %}
      <link rel="stylesheet" href="{% static "/bootstrap/css/bootstrap.min.css" %}">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
	      <link rel="stylesheet" href="{% static "/fonts/fontawesome-all.min.css" %}">
</head>
#check if the user is authenticated & show content below
{% if user.is_authenticated %}

#Page content