29 lines
860 B
Python
29 lines
860 B
Python
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("<h1>Post Creato con Successo!</h1>")
|
|
else:
|
|
form = FormTitolo()
|
|
context = {"form":form}
|
|
return render(request,"crea_titolo.html",context)
|