Titivillus/signup/views.py

24 lines
532 B
Python

#!/usr/bin/env python3
"""
/signup app views.
"""
# TODO: make unique username validation be case insensitive
from django.shortcuts import redirect, render
from .forms import SignupForm
def index(request):
"""
The signup page.
"""
if request.user.is_authenticated:
return redirect('homepage:index')
if request.method == 'POST':
form = SignupForm(request.POST)
if form.is_valid():
form.save()
return redirect('login:index')
else:
form = SignupForm()
return render(request, 'signup/index.html', {'form': form})