Advertisement
Nicolas_Darksoul

views.py

Dec 4th, 2021
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. from django.shortcuts import render
  2. from .models import Pizza,Topping
  3.  
  4.  
  5. def home(request):
  6.     return render(request,'pizzas/home.html')
  7.  
  8. def shops(request):
  9.     shops = Pizza.objects.order_by('date_added')
  10.     context = {'shops':shops}
  11.     return render(request,'pizzas/shops.html',context)
  12.  
  13. def pizza(request,pizza_id):
  14.     pizza = Pizza.objects.get(id=pizza_id)
  15.     describe = pizza.topping_set.order_by('-date_added')
  16.     context = {'pizza':pizza,'describe':describe}
  17.     return render(request,'pizzas/pizza.html',context)
  18.  
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement