end39

jp.dev 2020-11-21 04:29:34 -03:00
parent be7cdd5be4
commit 464777b678

@ -166,15 +166,37 @@ admin.site.register(Entrada, EntradasAdmin)
**/blog/urls.py** **/blog/urls.py**
``` ```
from django.urls import path from django.shortcuts import render
from . import views from blog.models import Entrada
from django.conf import settings # Create your views here.
from django.conf.urls.static import static
def blog(request):
urlpatterns = [ entradas = Entrada.objects.all()
path('', views.blog, name ='Blog'), return render(request, "blog/blog.html", {"entradas":entradas})
]
``` ```
- #### Editar plantilla
**/blog/blog.html**
```
{% extends 'ProyectoWebApp/base.html' %}
{% load static %}
{% block content %}
{% for entrada in entradas %}
<!-- Heading -->
<section class="page-section clearfix">
<div class="container">
<div class="intro">
<img class="intro-img img-fluid mb-3 mb-lg-0 rounded" src="{{entrada.imagen.url}}" alt="" style="width: 70%;">
<div class="intro-text left-0 text-center bg-faded p-5 rounded">
<h2 class="section-heading mb-4" >
<span class="section-heading-upper">{{entrada.titulo}}</span>
<span class="section-heading-lower" style="color: Tomato;">{{entrada.contenido}}</span>
</h2>
</div>
</div>
</div>
</section>
{% endfor %}
{% endblock %}
```