title: How display a bucle for 'post' in a booststrap carousel?
body: <p>I'm new to django and i'm doing my first project.</p>
  
  <p>my question is how display my posts in a bootstrap carrousel? </p>
  
  <p>I used: Boostrap 4.3.1
          Django 2.2</p>
  
  <p>this is my code:</p>
  
  <p>base.html</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;body&gt;
       ...
  &lt;/body&gt;
  &lt;/head&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>post_list.html</p>
  
  <pre><code>{% extends 'blog/base.html' %}
  
  {% block content %}
  &lt;br&gt;
  {% for post in posts %}
      &lt;div class="post"&gt;
          &lt;div class="date"&gt;
              &lt;p&gt;published: {{ post.published_date }}&lt;/p&gt;
          &lt;/div&gt;
          &lt;h1&gt;&lt;a href="{% url 'post_detail' pk=post.pk %}"&gt;{{ post.title }}&lt;/a&gt;    &lt;/h1&gt;
          &lt;h5 class="badge badge-secondary"&gt;by {{ post.author }}&lt;/h5&gt;
          &lt;p&gt;{{ post.text|linebreaksbr }}&lt;/p&gt;
          &lt;a href="{% url 'post_detail' pk=post.pk %}"&gt;Comments: {{     post.comments.count }}&lt;/a&gt;
      &lt;/div&gt;
  {% endfor %}
  {% endblock %}
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>from django.utils import timezone
  from django.contrib.gis.db import models
  
  
  class Post(models.Model):
      author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
      title = models.CharField(max_length=200)
      text = models.TextField()
      created_date = models.DateTimeField(
          default=timezone.now)
      published_date = models.DateTimeField(
          blank=True, null=True)
  
      def publish(self):
          self.publish_date = timezone.now()
          self.save()
  
  
      def __str__(self):
          return self.title
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>urlpatterns = [
      path('', views.post_list, name='post_list'),
      path('post/&lt;int:pk&gt;/', views.post_detail, name='post_detail'),
  ]
  </code></pre>
  
  <p>and views.py</p>
  
  <pre><code>from django.shortcuts import render
  
  
  def post_list(request):
      posts =Post.objects.filter(published_date__lte=timezone.now()).order_by('created_date')
      return render(request, 'blog/post_list.html', {'posts': posts})
  
  def post_detail(request, pk):
      posts = get_object_or_404(Post, pk=pk)
      return render(request, 'blog/post_detail.html', {'post': posts})
  </code></pre>
  
  <p>I tried with this code but it doesn´t work:</p>
  
  <pre><code>&lt;div class="carousel-inner"&gt;
  {% for post in posts|slice:":3" %}
      {% if forloop.first %}
          &lt;div class="active item"&gt;
      {% else %}
          &lt;div class="item"&gt;
     {% endif %}
          &lt;blockquote&gt;
              &lt;p&gt;{{ post.title }}&lt;/p&gt;
          &lt;/blockquote&gt;
          &lt;label&gt;{{ post.text }}&lt;/label&gt;
      &lt;/div&gt;
  {% endfor %}
  &lt;/div&gt;
  </code></pre>
  
  <p>I want it to look like this without the img:</p>
  
  <p><a href="https://i.stack.imgur.com/ea3Ef.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ea3Ef.png" alt="enter image description here"></a></p>
  
  <p>My template looks now:</p>
  
  <p><a href="https://i.stack.imgur.com/ikTAY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ikTAY.png" alt="enter image description here"></a></p>