Closed emptyset1 closed 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?
Glad that you ask. You can use the .instance_of(NewsPhotoItem) method that django-polymorphic provides to the queryset.
.instance_of(NewsPhotoItem)
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?