From 464777b67838b12b5de104f0880ce660d0ec1de1 Mon Sep 17 00:00:00 2001 From: "jp.dev" Date: Sat, 21 Nov 2020 04:29:34 -0300 Subject: [PATCH] end39 --- 7d_Proyecto_Web_Completo.md | 40 ++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/7d_Proyecto_Web_Completo.md b/7d_Proyecto_Web_Completo.md index a39e66d..2ec14be 100644 --- a/7d_Proyecto_Web_Completo.md +++ b/7d_Proyecto_Web_Completo.md @@ -166,15 +166,37 @@ admin.site.register(Entrada, EntradasAdmin) **/blog/urls.py** ``` - from django.urls import path - from . import views - from django.conf import settings - from django.conf.urls.static import static + from django.shortcuts import render + from blog.models import Entrada + # Create your views here. - - urlpatterns = [ - path('', views.blog, name ='Blog'), - ] + def blog(request): + entradas = Entrada.objects.all() + return render(request, "blog/blog.html", {"entradas":entradas}) ``` - \ No newline at end of file + - #### Editar plantilla + **/blog/blog.html** + ``` + {% extends 'ProyectoWebApp/base.html' %} + {% load static %} + {% block content %} + {% for entrada in entradas %} + +
+
+
+ +
+

+ {{entrada.titulo}} + {{entrada.contenido}} +

+
+
+
+
+ {% endfor %} + {% endblock %} + ``` + \ No newline at end of file