def registration_request(request):
    context = {}
    if (request.method == 'GET'):
        return render(request, 'onlinecourse/user_registration_bootstrap.html', context)
    elif (request.method == 'POST'):
        username = request.POST['username']
        password = request.POST['psw']
        first_name = request.POST['firstname']
        last_name = request.POST['lastname']
        user_exist = False
        try:
            User.objects.get(username=username)
            user_exist = True
        except:
            logger.error('New user')
        if (not user_exist):
            user = User.objects.create_user(username=username, first_name=first_name, last_name=last_name, password=password)
            login(request, user)
            return redirect('onlinecourse:index')
        else:
            context['message'] = 'User already exists.'
            return render(request, 'onlinecourse/user_registration_bootstrap.html', context)
def registration_request(request):
    context = {}
    if (request.method == 'GET'):
        return render(request, 'onlinecourse/user_registration_bootstrap.html', context)
    elif (request.method == 'POST'):
        username = request.POST['username']
        password = request.POST['psw']
        first_name = request.POST['firstname']
        last_name = request.POST['lastname']
        user_exist = False
        try:
            User.objects.get(username=username)
            user_exist = True
        except:
            logger.error('New user')
        if (not user_exist):
            user = User.objects.create_user(username=username, first_name=first_name, last_name=last_name, password=password)
            login(request, user)
            return redirect('onlinecourse:index')
        else:
            context['message'] = 'User already exists.'
            return render(request, 'onlinecourse/user_registration_bootstrap.html', context)