title: How to put a delete button beneath each post?
body: <p>The goal here is to add a delete button beneath every post, and once it is clicked, the corresponding row will be deleted from the table in the database.  </p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>from django.shortcuts import render, redirect
  from .forms import CreatePostForm
  from django.contrib import messages
  from .models import CreatePost
  
  def create_post(request):
      if request.method == 'POST':
          form = CreatePostForm(request.POST)
          if form.is_valid():
              post = form.save(commit = False)
              post.save()
              messages.success(request, f'The post has been created.')
              return redirect('home_page')
      else:
          form = CreatePostForm()
      return render(request, 'post/create_post.html', {'form': form})
  
  def view_post(request):
      context = CreatePost.objects.order_by('-dateCreated')
      return render(request, 'post/view_post.html', {'context': context})
  </code></pre>
  
  <p>So far, there is one page, <code>create_post.html</code>, that allows users to create a post.  There is a second page, <code>view_post.html</code>, that allows users to see all posts with the most recently added first.  I want to put a delete button beneath every post in <code>view_post.html</code>.  </p>
  
  <p><strong>view_post.html</strong></p>
  
  <pre><code>{% extends "home_page/base.html" %}
  {% load crispy_forms_tags %}
  {% block content %}
      &lt;h1&gt;Volunteer Opportunities&lt;/h1&gt;
  
      {% for x in context %}
      &lt;h4&gt;
          {{ x.task }}
          &lt;small class="text-muted"&gt;Date Required: {{ x.dateRequired }}&lt;/small&gt;
      &lt;/h4&gt;
      &lt;blockquote&gt;
          &lt;p&gt;{{ x.description }}&lt;/p&gt;
          &lt;p&gt;Date Posted: {{ x.dateCreated }}&lt;/p&gt;
      &lt;/blockquote&gt;
      &lt;hr&gt;
      {% endfor %}
  
  {% endblock content %}
  </code></pre>
  
  <p>I'm not sure if this is necessary, but below are <code>models.py</code> and the project <code>urls.py</code> file.  </p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>from django.db import models
  
  class CreatePost(models.Model):
      dateCreated = models.DateTimeField(auto_now_add = True)
      task =  models.CharField(max_length = 1000)
      description = models.TextField()
      dateRequired = models.DateField(null = True)
  </code></pre>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>from django.contrib import admin
  from django.urls import path, include
  from home_page.views import home
  from post.views import create_post, view_post
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('', home, name = 'home_page'),
      path('create_post/', create_post, name = "create_post"),
      path('view_post/', view_post, name = "view_post"),
  ]
  </code></pre>