29 lines
843 B
Python
Executable File
29 lines
843 B
Python
Executable File
from django.shortcuts import render,get_object_or_404,redirect
|
|
from .models import Titolo
|
|
from .forms import FormTitolo
|
|
from django.http import HttpResponse
|
|
|
|
# Create your views here.
|
|
|
|
def homepage(request):
|
|
titoli = Titolo.objects.all().order_by("-unico")
|
|
context = {"titoli":titoli}
|
|
return render(request,"Homepage.html",context)
|
|
|
|
|
|
def guarda_streaming(request,id):
|
|
streaming = get_object_or_404(Titolo,id=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 redirect("Homepage")
|
|
else:
|
|
form = FormTitolo()
|
|
context = {"form":form}
|
|
return render(request,"crea_titolo.html",context)
|