Created
June 27, 2020 13:03
-
-
Save awg01/66e62f86f6bf4440bc347e83799e1a97 to your computer and use it in GitHub Desktop.
"Update 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
"Delete Albums Functionality" Code for Django Tutorial for Beginners - 32 - UpdateView and DeleteView | |
{% extends 'music/base.html' %} | |
{% block title %}Album Details{% endblock %} | |
{% block body %} | |
<img src="{{ album.album_logo }}" alt=""> | |
<!-- Just add this code inside your detail.html for updating albums.Simple Code for demonstration of | |
functionality.If you understand this then you can design page according to your need. | |
Dont forget to write method name of form is POST.Add this code snippet in your detail.html --> | |
<!-- start --> | |
<form action="{% url 'music:album-update' album.id %}" method="get" class="form-group"> | |
{% csrf_token %} | |
<input type="hidden" name="album_id" value="{{album.id}}" /> | |
<button type="submit" class="btn btn-default btn-sm"> | |
Update Album | |
</button> | |
</form> | |
<!-- end of snippet --> | |
<h1>{{ album.album_title }}</h1> | |
<h2>{{ album.genre }}</h2> | |
<h2>{{ album.artist}}</h2> | |
{% for song in album.song_set.all %} | |
{{song.song_title}} | |
{% if song.is_favourite %} | |
** | |
{% endif %} | |
<br> | |
{% endfor %} | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment