blechreiz-website/intern_area/views.py

37 lines
1.0 KiB
Python

# Create your views here.
from django.shortcuts import render
from django.contrib.auth import authenticate, login
from django.shortcuts import redirect
def login_site(request):
return render( request, 'intern_area/login.html')
def main_view(request):
pass
def login_site2(request):
if request.method == 'POST': # If the form has been submitted...
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
if not request.POST.get('remember', None):
request.session.set_expiry(0)
login(request, user)
return redirect( main_view )
else:
pass
# Return a 'disabled account' error message
else:
pass
# Return an 'invalid login' error message.
else:
return render( request, 'intern_area/login.html')