musik/base/views.py

25 lines
782 B
Python
Raw Normal View History

from django.contrib.auth.models import User
from django.contrib.messages.views import SuccessMessageMixin
from django.shortcuts import redirect
from django.urls import reverse_lazy
2025-06-13 15:51:32 +02:00
from django.views.generic.base import TemplateView
from django.views.generic.edit import CreateView
from . import forms
2025-06-13 15:51:32 +02:00
class HomePageView(TemplateView):
template_name = "index.html"
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated:
return redirect("home")
return super().dispatch(request, *args, **kwargs)
class SignupView(SuccessMessageMixin, CreateView):
model = User
form_class = forms.UserSignupForm
success_url = reverse_lazy("login")
success_message = "Le compte %(username)s a été créé avec succès."