Skip to content

Instantly share code, notes, and snippets.

@awg01
Created June 27, 2020 13:03
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/66e62f86f6bf4440bc347e83799e1a97 to your computer and use it in GitHub Desktop.
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
"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