Django: How to write an if statement

bibibobo265

New Member
I want to get the list of songs under the list of artists.My artist class just contains the artists first and last name.My song class contains a foreign key of an artist along with the song title.I am able to list the artists but when I try to list the songs of the artist I get and error in my {% endif %} that ends my if statement {% if song %}. \[code\]{% extends "base.html" %} {% block heading %}Music Catalog{% endblock %} {% block content %} {% if user.username %} <p>Welcome {{ user.username }}!</p> {% if artist %} <u1> {% for singer in artist %} <li>{{ singer.firstname }} {{ singer.lastname }}</li> {% if song %} <u1> {% for songs in song %} {% if (songs.artist.firstname == singer.firstname and songs.artist.lastname == singer.lastname) %} <li>{{ songs.title }}</li> {% endif %} {% endfor %} </u1> {% endif %} {% endfor %} </u1> {% else %} <p>No artists were found in the music catalog.</p> {% endif %} {% else %} <p>You need to <a href="http://stackoverflow.com/login/">login</a> to see your music catalog.</p> {% endif %} {% endblock %} enter code here\[/code\]
 
Back
Top