I also, I have build one program with health environment, and the user controlls is following manner:
def login_ini(request):
variable1 = 'Pantalla de Acceso al Sistema'
error_log = 'ok'
username = request.POST.get('username')
password = request.POST.get('password') # valor del template
user = auth.authenticate(username=username, password=password)
if request.method == "POST":
if user is not None and user.is_active:
# Correct password, and the user is marked "active"
auth.login(request, user)
request.session['username_x'] = username # variable gobal
request.session['id_x'] =
user.id # variable gobal
#return HttpResponse(str(
user.id))
return HttpResponseRedirect("principal")
error_log = "error"
context ={"variable1":variable1,"error_log":error_log,}
return render(request,"login_ini.html",context)
context ={
'user':user,
"variable1":variable1,
"error_log":error_log,
}
return render(request,'login_ini.html',context)