from django.contrib.auth import login, logout, authenticate
from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response, redirect

def user_login(request):

    if request.method == 'POST':
        username = request.POST.get['username']
        password = request.POST.get['password']
    	user = authenticate(username=username, password=password)
        if user is not None:
            login(request, user)
            return render_to_response('../templates/side_bar.html', {'username':username})
        else
            return redirect('index') #when the user not in SQL
    else
        return redirect('index') #when request.method is not POST

@login_required()   #needChange: (login_url='/teacher/login'  or /strudent/login)
def user_logout(request):
    logout(request)
    return redirect('index')

@@ -540,16 +540,32 @@
 ername%7D)
+ #needChange:URL
 %0A       
@@ -561,32 +561,33 @@
 URL%0A        else
+:
 %0A            ret
@@ -642,16 +642,17 @@
     else
+:
 %0A       
@@ -711,16 +711,16 @@
 t POST%0A%0A
+
 @login_r
@@ -743,17 +743,16 @@
 dChange:
- 
 (login_u

debug user_login