added get_instances_from_related method for product document
This commit is contained in:
parent
b9e6df5482
commit
1981b44a10
|
|
@ -177,3 +177,12 @@ class ProductDocument(Document):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return super().get_queryset().published().with_base_related()
|
return super().get_queryset().published().with_base_related()
|
||||||
|
|
||||||
|
def get_instances_from_related(self, related_instance):
|
||||||
|
"""If related_models is set, define how to retrieve the Product instance(s) from the related model.
|
||||||
|
The related_models option should be used with caution because it can lead in the index
|
||||||
|
to the updating of a lot of items.
|
||||||
|
"""
|
||||||
|
if isinstance(related_instance, models.ProductType) and hasattr(related_instance, 'product_set'):
|
||||||
|
return related_instance.product_set().all()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user