I want to compute some custom
variable based on the other block values in the StructBlock
and add this custom
variable to the template context. Essentially I should be able to use this computed variable in the StructBlock
template like so {{ value.custom }}
.
Here's my StructBlock
:
class BaseBlock(blocks.StructBlock):
bool_fld = blocks.BooleanBlock(required=False, default=False)
def get_context(self, *a, **kw):
ctx = super().get_context(*a, **kw)
ctx['custom'] = 1 if self.bool_fld else 0
return ctx
And the error:
'BaseBlock' object has no attribute 'bool_fld'
Any ideas?