Files
fln-django-template/apps/core/views.py
2026-03-01 07:03:16 +07:00

39 lines
1.1 KiB
Python

from django.shortcuts import render
from django.views.generic import TemplateView, View, CreateView
from .models import CustomUserLogin
from .forms import RegisterForm
# Create your views here.
class Template403View(TemplateView):
template_name = "403.html"
class Template404View(TemplateView):
template_name = "404.html"
class LogoutView(View):
def get(self, request, *args, **kwargs):
request.session.flush()
return redirect(settings.LOGOUT_REDIRECT_URL)
class DashboardView(TemplateView):
template_name = "pages/dashboard.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["menu"] = "Dashboard"
return context
class FormView(CreateView):
template_name = "pages/form.html"
model = CustomUserLogin
form_class = RegisterForm
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["menu"] = "Dashboard"
context["card_form"] = "Register Form"
context["card_list"] = "List View"
context["items"] = self.model.objects.all()
return context