homelog/container/views.py

43 lines
1.2 KiB
Python

from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
from django.http import Http404
from django.urls import reverse
from django.views import generic
from .models import Container, ContainerType
class IndexView(generic.ListView):
template_name = 'container/container_index.html'
context_object_name = 'container_list'
def get_queryset(self):
# Return the last five created containers
return Container.objects.order_by('-created_ts')[:5]
class TypeIndexView(generic.ListView):
template_name = 'container/container_type_index.html'
context_object_name = 'container_type_list'
def get_queryset(self):
# Return the last five created container types
return ContainerType.objects.order_by('-created_ts')[:5]
class DetailView(generic.DetailView):
model = Container
# template_name = 'container/detail.html'
class TypeDetailView(generic.DetailView):
model = ContainerType
context_object_name = 'container_type'
template_name = 'container/container_type_detail.html'
class EditView(generic.DetailView):
model = Container
class DeleteView(generic.DetailView):
model = Container
class AddView(generic.DetailView):
model = Container