Hi,
In my models I have an event index page type, which can have child event pages, each event page can be tagged (using taggit), and I want to produce a list of distinct tags used in the events that belong to that event index on the index itself. I'm using the Django CMS Wagtail, but I guess this is really a Django ORM query question. I''ve got some code as part of my model which is working but I don't think it's the most efficient way of doing this. Still trying unlearn doing things with SQL and learn how the same thing should be done in Django.
My code as part of the event index class is
@property
def event_tag_list(self):
child_events = EventPage.objects.live().descendant_of(self)
return Tag.objects.filter(mysite_eventpagetag_items__isnull=False).filter(mysite_eventpagetag_items__content_object_id=child_events).order_by('slug').distinct('slug')
Any feedback would be appreciated.
Thanks
Joss