title: Deleting a Post from a Stream
body: <p>I am new to creating web applications, and I decided to start out by learning Flask. I am making a Social Network as a side-project to practice and learn some basic skills. </p>
  
  <p>So far, I have been able to build a "Stream" that users can post to, kind of like Twitter. <strong>I have been struggling to find a way to allow users to Delete posts.</strong> I am using a SQLite database with the Peewee library. Here is what I have tried: </p>
  
  <pre><code>@app.route('/delete_post/&lt;int:post_id&gt;')
  @login_required
  def delete_post(post_id):
      delete = models.Post.select().where(models.Post.id == post_id)
      try:
          models.DATABASE.delete(delete)
      except models.DoesNotExist:
          abort(404)
      else:
          flash("This post has successfully been deleted.", "success")
      return redirect(url_for('stream', stream = stream))
  </code></pre>
  
  <p>Also, here is how a Post is created:</p>
  
  <pre><code>class Post(Model):
      timestamp = DateTimeField(default=datetime.datetime.now())
      user = ForeignKeyField(
          rel_model= User,
          related_name='posts'
      )
      content = TextField()
      class Meta:
          database = DATABASE
          order_by = ('-timestamp',)
  </code></pre>
  
  <p>Finally, there is the template where the delete_post method would be called when the use selects "Delete"</p>
  
  <pre><code>{% extends "base.html" %}
  
  {% block content %}
  {% for post in stream %}
      &lt;article&gt;
          &lt;h2&gt;
              &lt;a href="{{ url_for('stream', username=post.user.username) }}"&gt;{{ post.user.username }}&lt;/a&gt;
          &lt;/h2&gt;
          &lt;i class="clock"&gt;&lt;/i&gt;
          &lt;time&gt;
          {{ post.timestamp.strftime("%a, %d %b %Y %H:%M") }}
          &lt;/time&gt;
          &lt;a href="{{ url_for('view_post', post_id=post.id) }}" class="view"&gt;View&lt;/a&gt;
          &lt;a href="{{ url_for('delete_post', post_id=post.id) }}" class="view" &gt;| Delete&lt;/a&gt;
  
          &lt;div class="post"&gt;
              {{ post.content }}
          &lt;/div&gt;
      &lt;/article&gt;
  {% endfor %}
  {% endblock %}
  </code></pre>
  
  <p><strong>How do I go about deleting a post?</strong> When I try my solution I get: <code>AttributeError: 'SqliteDatabase' object has no attribute 'delete'</code>
  I know this question is pretty long-winded, but any help would be much appreciated and would help me a lot in future projects. Let me know if I need to clarify anything else.</p>
  
  <p>Thanks!</p>