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:
[image: Song-Chord-Hierarchy.png]
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
--
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mezzanine-users/0cffd480-dc2f-43df-ad48-c2110bb5b96cn%40googlegroups.com.