34 lines
1015 B
Python
Executable File
34 lines
1015 B
Python
Executable File
from django.shortcuts import render,redirect, get_object_or_404
|
|
from django.views.generic import (
|
|
ListView,
|
|
DetailView,
|
|
View
|
|
)
|
|
from camper.models import Offer, Image_offer
|
|
from django.http import Http404, HttpResponseRedirect
|
|
from django.core.paginator import Paginator ,EmptyPage, PageNotAnInteger
|
|
|
|
class Home(View):
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
return render(request, 'index.html')
|
|
|
|
class OfferDetailView(DetailView):
|
|
template_name = 'offer/offer-detail.html'
|
|
model = Offer
|
|
context_object_name = 'offer'
|
|
|
|
class OfferListView(ListView):
|
|
model = Offer
|
|
template_name = 'offer/offers.html'
|
|
context_object_name = 'active_offers_list'
|
|
paginate_by = 4
|
|
|
|
ordering = ['-date_added']
|
|
|
|
def get_queryset(self):
|
|
return Offer.objects.filter(status = 'Active')
|
|
|
|
#def book_detail_view(request, primary_key):
|
|
# book = get_object_or_404(Book, pk=primary_key)
|
|
# return render(request, 'catalog/book_detail.html', context={'book': book}) |