Hi there!
I have four models: "Encyclopedia", "Song", "Section", "Chord". In the admin panel I have set this up with Encyclopedia being parent to Song being parent to Section being parent to Chord (i.e. there's an Encyclopedia which has a bunch of Songs, each Song is made of Sections, each Section has a bunch of Chords). The admin looks like this:
1) How can I query the Song dataset to access all its child Chords? (i.e. for each Song, return a list of all Chords)
My current method is to make datasets for Songs, Sections and Chords, pass these datasets to the html file, then script the html as so:
{% for song in songs %}
{% for section in sections %}
{% if section.parent.title == song.title %}
{% for chord in chords %}
{% if chord.parent.title == section.title and chord.parent.parent.title == section.parent.title %}
[ do stuff ]
I'd greatly appreciate advice on better practices for this!
2) How can I query the Chord dataset to access what Song is the parent? Chord.parent gives me the full hierarchy, but I can't work out if there's a way to specifically jump up two levels (in this instance Chord is child to Section, and Section is child to Song, and Song is what I'm looking to identify).
Thanks!
Rich