Skip to content

Instantly share code, notes, and snippets.

@Elise-Lennion
Created October 20, 2018 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elise-Lennion/0d83a7e34d2d7173013546114f1689bf to your computer and use it in GitHub Desktop.
Save Elise-Lennion/0d83a7e34d2d7173013546114f1689bf to your computer and use it in GitHub Desktop.
from django.contrib.auth.forms import AuthenticationForm
from django.shortcuts import render
from research.forms import UserCreateForm # Custom register form
def front_page_view(request):
if request.method == 'POST':
if 'login_form' in request.POST:
login_form = AuthenticationForm(request=request, data=request.POST)
register_form = UserCreateForm()
# Do things for the login form
elif 'register_form' in request.POST:
login_form = AuthenticationForm()
register_form = UserCreateForm(request.POST)
# Do things for the register form
else:
login_form = AuthenticationForm()
register_form = UserCreateForm()
return render(request, 'front_page.html', {'register_form': register_form, 'login_form': login_form})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment