How to use DAL for this query

28 views
Skip to first unread message

Nino Cocchiarella

unread,
May 18, 2014, 10:14:30 AM5/18/14
to django...@googlegroups.com
I'm working with Django... I am used to writing raw SQL queries, so the DAL is a little comfusing for me.  But, apperantly, its the thing to do.
Anyway, come anyone point me in the right direction on how to translate this raw query into the Django DAL --

SELECT *  FROM rep_musicalwork, rep_composer WHERE rep_musicalwork.composer_id = rep_composer.id ORDER BY rep_composer.last_name, rep_composer.first_name;

Nino Cocchiarella

unread,
May 18, 2014, 11:20:50 AM5/18/14
to django...@googlegroups.com
Solved by using this:
works = MusicalWork.objects.select_related('composer').all()

And accessing it with this
str(item.title) + ' -- ' + str(item.composer.last_name)
Reply all
Reply to author
Forward
0 new messages