Skip to content

Instantly share code, notes, and snippets.

@awg01
Last active November 3, 2020 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awg01/5f0ed3a824a931fe9bb122c761890aec to your computer and use it in GitHub Desktop.
Save awg01/5f0ed3a824a931fe9bb122c761890aec to your computer and use it in GitHub Desktop.
"Delete Albums Functionality" Code for Django Tutorial for Beginners - 32 - UpdateView and DeleteView
{% extends 'music/base.html' %}
{% block body %}
{% if all_albums %}
<h3>All Albums : </h3>
<ul type='none'>
<!-- Just add this code inside your index.html for deleting albums.Simple Code for demonstration of
functionality.If you understand this then you can design page according to your need. -->
{% for album in all_albums %}
<li>
<div class="inline-form">
<a href="{% url 'music:detail' album.id %}" class="form-group">{{album.album_title}}</a>
<form action="{% url 'music:album-delete' album.id %}" method="post" class="form-group">
{% csrf_token %}
<input type="hidden" name="album_id" value="{{album.id}}" />
<button type="submit" class="btn btn-default btn-sm">
Delete Album
</button>
</form>
</div>
</li>
{% endfor %}
</ul>
{% else %}
<p>No album found.</p>
{% endif %}
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment