Using bootstrap and better view resolution

This commit is contained in:
2022-03-10 11:33:06 +01:00
parent 02bc2f4667
commit 7e446bcbec
23 changed files with 438 additions and 58 deletions

View File

@@ -2,27 +2,39 @@ 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
def index(request):
container_list = Container.objects.order_by('-created_ts')[:5]
container_type_list = ContainerType.objects.order_by('-created_ts')[:5]
ctx = {'container_list': container_list, 'container_type_list': container_type_list}
return render(request, 'container/index.html', ctx)
class IndexView(generic.ListView):
template_name = 'container/container_index.html'
context_object_name = 'container_list'
def container_type_details(request, container_type_id):
try:
ctype = ContainerType.objects.get(pk=container_type_id)
except ContainerType.DoesNotExist:
raise Http404("Container Type does not exist")
return render(request, 'container/container_type_details.html', {'container_type': ctype})
def get_queryset(self):
# Return the last five created containers
return Container.objects.order_by('-created_ts')[:5]
def container_details(request, container_id):
try:
container = Container.objects.get(pk=container_id)
except Container.DoesNotExist:
raise Http404("Container does not exist")
return render(request, 'container/container_details.html', {'container': container})
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