Last active
November 3, 2020 08:36
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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