from django.shortcuts import render, redirect;
from django.contrib import auth;

def logout(request):
    auth.logout(request)
    return redirect('/')

def login(request):
    if request.method == "GET":
        return render(request, "auth/login.html");
    elif request.method == "POST":
        username = request.POST['username'];
        password = request.POST['password'];

        # make sure the username & password is good
        user = auth.authenticate(username=username, password=password);

        if user is not None: # User was found & password matched
            if user.is_active:
                #associate the user with the session
                auth.login(request, user);

                #read the destination
                next = "";
                if "next" in request.GET:
                    next = request.GET["next"];
                if next == None or next == "":
                    next = "/";
                return redirect(next);
            else:
                #account disabled
                return render(request, "auth/login.html", { "warning": "Your account is disabled" });
        else:
            # bad username and password
            return render(request, "auth/login.html", { "warning": "Invalid username and or password" });

def register(request):
    if request.method == "GET":
        return render(request, "auth/register.html");
    elif request.method == "POST":
        username = request.POST["username"];
        password = request.POST["password"];
        email = request.POST["email"]
        if not username.exists():
            # call create_user from the ORM. Make sure you call save!
            auth.models.User.objects.create_user(username, email, password).save();
            #log the user in
            user = auth.authenticate(username = username, password = password);
            auth.login(request, user);
            return render(request, "auth/registered.html");
        else:
            return render(request, "auth/register.html", { "warning": "Username already exist" });


@@ -1557,46 +1557,8 @@
 l%22%5D%0A
-        if not username.exists():%0A    
     
@@ -1619,20 +1619,16 @@
 l save!%0A
-    
         
@@ -1707,20 +1707,16 @@
         
- 
-   
 #log the
@@ -1724,20 +1724,16 @@
 user in%0A
-    
         
@@ -1800,20 +1800,16 @@
 sword);%0A
-    
         
@@ -1835,36 +1835,32 @@
  user);%0A        
-    
 return render(re
@@ -1894,119 +1894,6 @@
 l%22);
-%0A        else:%0A            return render(request, %22auth/register.html%22, %7B %22warning%22: %22Username already exist%22 %7D);
 %0A%0A

Update auth.py