from django.shortcuts import render,get_object_or_404 from .models import Titolo from .forms import FormTitolo from django.http import HttpResponse # Create your views here. def homepage(request): titoli = Titolo.objects.all() context = {"titoli":titoli} return render(request,"Homepage.html",context) def guarda_streaming(request,slug_id): streaming = get_object_or_404(Titolo,slug_id=slug_id) context = {"streaming":streaming} return render(request,"streaming.html",context) def CreateTitolo(request): if request.method == "POST": form = FormTitolo(request.POST) if form.is_valid(): new_title = form.save() return HttpResponse("

Post Creato con Successo!

") else: form = FormTitolo() context = {"form":form} return render(request,"crea_titolo.html",context)