123456789101112131415161718192021222324252627282930313233343536373839404142 |
- from django.contrib.auth.forms import AuthenticationForm
- from django.contrib.auth.views import LoginView
- from django.shortcuts import render
- from django.urls import reverse_lazy
- from django.views.generic import ListView, CreateView, UpdateView
- from .models import *
- from .forms import *
- class Index(ListView):
- model = Service
- template_name = 'index.html'
- paginate_by = 5
- def get_queryset(self):
- return Service.objects.order_by('-date')
- def index(self):
- return render(self, 'index.html')
- class AllService(ListView):
- def all(self):
- return render(self, 'all.html')
- class Registration(CreateView):
- form_class = RegistrationForm
- template_name = 'user/registration.html'
- success_url = reverse_lazy('login')
- def registration(self):
- return render(self, 'user/registration.html')
- class LoginView(LoginView):
- form_class = AuthenticationForm
- template_name = 'user/login.html'
- success_url = reverse_lazy('profile')
- class Profile(UpdateView):
- model = User
- fields = ['username', 'name', 'surname', 'avatar']
- success_urls = reverse_lazy('profile')
- template_name = 'user/profile.html'
|