Make it possible to add a new platform

This commit is contained in:
2023-01-04 17:23:34 +01:00
parent 4c642d97cb
commit bf61326c18
5 changed files with 23 additions and 2 deletions

View File

@ -1,7 +1,7 @@
from django.shortcuts import render
from .models import Game, Platform, Purchase, Session
from .forms import SessionForm, PurchaseForm, GameForm
from .forms import SessionForm, PurchaseForm, GameForm, PlatformForm
from datetime import datetime
def model_counts(request):
return {
@ -66,6 +66,18 @@ def add_game(request):
context["title"] = "Add New Game"
return render(request, "add.html", context)
def add_platform(request):
context = {}
form = PlatformForm(request.POST or None)
if form.is_valid():
form.save()
context["form"] = form
context["title"] = "Add New Platform"
return render(request, "add.html", context)
def index(request):
context = {}
return render(request, "index.html", context)