You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
padelclub_backend/tournaments/custom_views.py

20 lines
728 B

from django.contrib import messages
from django.contrib.auth import views as auth_views
from django.urls import reverse
from .forms import EmailOrUsernameAuthenticationForm
class CustomLoginView(auth_views.LoginView):
template_name = 'registration/login.html'
authentication_form = EmailOrUsernameAuthenticationForm
def get_success_url(self):
next_url = self.request.POST.get('next')
print("CustomLoginView", "next_url", next_url, self.request.GET)
if next_url:
return next_url
else:
return reverse('index')
def get(self, request, *args, **kwargs):
messages.get_messages(request).used = True
return super().get(request, *args, **kwargs)