Geoffrey-Django/views.py

40 lines
865 B
Python

from django.shortcuts import render
from django.views.generic import View
from GeoffreyApp.models import *
from django.views import generic
# Create your views here.
class Home(View):
def get(self, request):
base_num = Base.objects.count()
shop_num = Shop.objects.count()
player_num = Player.objects.count()
item_num = ItemListing.objects.count()
context = {
"num_players": player_num,
"num_bases": base_num,
"num_shops": shop_num,
"num_items": item_num,
}
return render(request, 'GeoffreyApp/home.html', context=context)
class PlayerList(generic.ListView):
model = Player
class ShopList(generic.ListView):
model = Shop
class BaseList(generic.ListView):
model = Base
class ItemListingList(generic.ListView):
model = ItemListing