From e444c74ea7d48baeff4e18e0432870e15a3066ba Mon Sep 17 00:00:00 2001 From: Bruno Cesar Date: Sat, 7 Nov 2020 15:18:31 -0300 Subject: [PATCH] =?UTF-8?q?Recupera=20cole=C3=A7=C3=A3o=20de=20receitas=20?= =?UTF-8?q?e=20apresenta=20na=20view?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/receitas/templates/index.html | 23 +++++++++++++---------- apps/receitas/views.py | 11 ++--------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/apps/receitas/templates/index.html b/apps/receitas/templates/index.html index 688e4f5..658a148 100755 --- a/apps/receitas/templates/index.html +++ b/apps/receitas/templates/index.html @@ -14,18 +14,21 @@
- {% for chave, valor in nome_das_receitas.items %} -
-
- -
- -
{{ valor }}
-
+ {% if receitas %} + {% for receita in receitas %} + -
- {% endfor %} + {% endfor %} + {% else %} + {% endif %}
diff --git a/apps/receitas/views.py b/apps/receitas/views.py index 2ca9994..05492c5 100644 --- a/apps/receitas/views.py +++ b/apps/receitas/views.py @@ -1,15 +1,8 @@ from django.shortcuts import render +from .models import Receita def index(request): - - receitas = { - 1: 'Vitamina de Banana', - 2: 'Nhoque de Batatinha', - 3: 'Bolo de Cenoura' - } - dados = {'nome_das_receitas': receitas} - - return render(request, 'index.html', dados) + return render(request, 'index.html', {'receitas': Receita.objects.all()}) def receita(request): return render(request, 'receita.html')