Skip to content
Snippets Groups Projects
Commit 82ebd29e authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

Création de la vue pour une pizza.

parent 81700051
Branches
No related tags found
No related merge requests found
...@@ -70,7 +70,7 @@ header { ...@@ -70,7 +70,7 @@ header {
.navbar .nav-link { .navbar .nav-link {
height: 100%; height: 100%;
margin-right: .25rem;
} }
.navbar .nav-link.active, .navbar .nav-link:hover { .navbar .nav-link.active, .navbar .nav-link:hover {
......
{% extends 'applipizza/base.html' %}
{% load static %}
{% block title %}
Lasri Del Arte - Pizza {{ pizza }}
{% endblock %}
{% block content %}
<div class="container">
<h2>Pizza {{ pizza }}</h2>
<p>Une délicieuse pizza traditionnelle.</p>
</div>
{% endblock %}
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
{% load static %} {% load static %}
{% block title %} {% block title %}
Pizza Corp Lasri Del Arte - Nos pizzas
{% endblock %} {% endblock %}
{% block content %} {% block content %}
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<div class="body"> <div class="body">
<h5>{{ p.nom }}</h5> <h5>{{ p.nom }}</h5>
<p>La grande classique, l’éternelle Margherita</p> <p>La grande classique, l’éternelle Margherita</p>
<a class="btn success" href="/pizzas/{{ p.id }}">Commander - {{ p.prix }} €</a> <a class="btn success" href="/pizza/{{ p.id }}">Commander - {{ p.prix }} €</a>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
......
from django.shortcuts import render from django.shortcuts import render
from applipizza.models import Pizza, Ingredient, Composition from applipizza.models import Pizza, Ingredient, Composition
# Create your views here. # Create your views here.
def pizzas(request): def pizzas(request):
pizzas = Pizza.objects.all() pizzas = Pizza.objects.all()
...@@ -9,3 +10,13 @@ def pizzas(request): ...@@ -9,3 +10,13 @@ def pizzas(request):
'applipizza/pizzas.html', 'applipizza/pizzas.html',
{'pizzas': pizzas} {'pizzas': pizzas}
) )
def pizza(request, id):
pizza = Pizza.objects.get(id=id)
print(pizza)
return render(
request,
'applipizza/pizza.html',
{'pizza': pizza}
)
...@@ -20,5 +20,6 @@ from applipizza import views ...@@ -20,5 +20,6 @@ from applipizza import views
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('pizzas/', views.pizzas) path('pizzas/', views.pizzas),
path('pizza/<int:id>', views.pizza)
] ]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment