-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
- wagtail_cache_block version: 0.1.3
- Django version: 2.2
- Python version: 3..6
- Operating System: Linux
Description
I used the cache_block template tag{% cache_block 300 request block %}...
{% for card in self.product_cards %}
{% cache_block 300 request card %}
{% include_block card with request=request block=card only %}
{% endcache_block %}
{% endfor %}
...and got the following error
AttributeError at /
'ProductCardValue' object has no attribute 'value'
The error happened on this line of code for k, v in block_obj.value.bound_blocks.items(): which is in the middle of the below code...
def extract_block(block_obj):
"""
Extract block values to vary_on list
"""
vary_on = []
if isinstance(block_obj.block, StructBlock):
tmp_dict = {}
for k, v in block_obj.value.bound_blocks.items():
tmp_dict[k] = extract_block(v)
vary_on.append({block_obj.block.name: tmp_dict})
elif isinstance(block_obj.block, StreamBlock):
tmp_ls = []
for child in block_obj.value:
sub_value = extract_block(child)
The block_obj is a ProductCardValue object which is this below:
class ProductCardValue(StructValue):
def review_aggregate_data(self):
...
return {}
def product_info(self):
...
return {}
The ProductCardValue is used by the ProductCardBlock as seen below:
class ProductCardBlock(blocks.StructBlock):
title_link = LinkBlock(help_text='The title of the product')
image_link = LinkBlock(required=False, help_text='The main image with a link')
body = blocks.RichTextBlock(required=False, features=RICH_TEXT_FEATURES)
product_id = blocks.ChoiceBlock(required=False, choices=PRODUCT_CHOICES, help_text='The product')
show_product_reviews = blocks.BooleanBlock(required=False, help_text='Do you want to show the product review stars?')
class Meta:
template = 'streams/product_card_block.html'
icon = 'placeholder'
label = 'Product Card'
value_class = ProductCardValue
Does this not work if you are using a value_class?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels