Source code for accounts.views
from django.shortcuts import render
from django.http import HttpResponse
from django.contrib.auth import get_user_model,logout
from django.contrib.auth.forms import UserCreationForm
from django.urls import reverse_lazy
from django.views.generic import CreateView
from django.contrib.auth.views import LogoutView
from.forms import RegisterForm
# Create your views here.
[docs]
class SignupView(CreateView):
form_class = RegisterForm
success_url = reverse_lazy("login")
template_name = "registration/register.html"
[docs]
def check_username(request):
username = request.POST.get('username')
if get_user_model().objects.filter(username=username).exists():
return HttpResponse("This username already exists")
else:
return HttpResponse("")
[docs]
class LoginView(CreateView):
my_flag=''
template_name = 'registration/login.html' # Specify your custom template here
[docs]
class CellarLogoutView(LogoutView):
print('In Accounts: CellarLogout View')
my_flag=''
template_name = 'accounts/logout.html' # Specify your custom template here