<reponame>Triple-Z/Python-Crash-Course
from django.shortcuts import render
from .models import Pizza, Topping


def index(request):
    return render(request, 'pizzas/index.html')


def pizzas(request):
    pizzas = Pizza.objects.order_by('name')
    context = {'pizzas': pizzas}
    return render(request, 'pizzas/pizzas.html', context)


def pizza(request, pizza_id):
    pizza = Pizza.objects.get(id=pizza_id)
    toppings = pizza.topping_set.order_by('name')
    context = {
        'pizza': pizza,
        'toppings': toppings,
    }
    return render(request, 'pizzas/pizza.html', context)

from django.shortcuts import render
from .models import Pizza, Topping


def index(request):
    return render(request, 'pizzas/index.html')


def pizzas(request):
    pizzas = Pizza.objects.order_by('name')
    context = {'pizzas': pizzas}
    return render(request, 'pizzas/pizzas.html', context)


def pizza(request, pizza_id):
    pizza = Pizza.objects.get(id=pizza_id)
    toppings = pizza.topping_set.order_by('name')
    context = {
        'pizza': pizza,
        'toppings': toppings,
    }
    return render(request, 'pizzas/pizza.html', context)