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**
```
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})
```
- #### 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 %}
```