title: Delete image in Django
body: <p>I have to delete image from my app. Image has to be deleted from "media" file (directory inside my project) and from database.
  Here is my class DeleteImage</p>
  
  <pre><code>class DeleteImage(DeleteView):
      template_name = 'layout/delete_photo.html'
      model = Profile
      success_url = reverse_lazy('git_project:add_photo')
  </code></pre>
  
  <p>This is HTML page</p>
  
  <pre><code>{% extends 'layout/base.html' %}
  {% block body %}
  {% if allprofiles %}
  &lt;ul&gt;
  {% for profile in allprofiles %}
      &lt;li&gt;
          &lt;img src="/{{ profile.image }}" height="75" /&gt;
          &lt;a href="{% url 'git_project:delete_photo' user.profile.id %}"&gt;Delete&lt;/a&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  {% endfor %}
  {% endif %}
  {% endblock %}
  </code></pre>
  
  <p>I don't know if you need models.py</p>
  
  <pre><code>class Profile(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE)
      image = models.FileField()
  </code></pre>
  
  <p>Can anyone help me with this? I saw all similar Questions and Answers but can't figure this issue out... :)</p>