123456789101112131415161718192021222324252627 |
- from django.contrib.auth.forms import UserCreationForm
- from django.contrib.auth.views import LoginView
- from django.shortcuts import render, redirect
- from django.urls import reverse_lazy
- from django.views.generic import CreateView
- from .models import Product, UserProfile
- def index(request):
- products = Product.objects.all()[:5]
- return render(request, 'index.html', {'products': products})
- def products(request):
- products = Product.objects.all()
- return render(request, 'products.html', {'products': products})
- class BBLoginView(LoginView):
- template_name = 'login.html'
- class RegistrationUserView(CreateView):
- model = UserProfile
- form_class = UserCreationForm
- template_name = 'registration.html'
- success_url = reverse_lazy('login')
|