django-fluent / django-fluent-contents

A widget engine to display various content on Django pages
http://django-fluent.org/
Apache License 2.0
149 stars 39 forks source link

Quering ContentItemRelation() #75

Closed emptyset1 closed 8 years ago

emptyset1 commented 8 years ago

Hi, I've been at it for a couple of days now. Would really appreciate help.

models.py: class Story(models.Model): ... content = PlaceholderField("story_content") placeholder_set = PlaceholderRelation() contentitem_set = ContentItemRelation() ...

views.py: chosen_story = get_object_or_404(Story, slug=slug) photos = chosen_story.contentitem_set.all()

How do I query "photos" above to get only ContentItem(s) of class NewsPhotoItem with this particular parent?

vdboor commented 8 years ago

Glad that you ask. You can use the .instance_of(NewsPhotoItem) method that django-polymorphic provides to the queryset.