get_context methods on StreamField blocks need updating¶

Previously, get_context methods on StreamField blocks returned a dict of variables which would be merged into the calling template’s context before rendering the block template. get_context methods now receive a parent_context dict, and are responsible for returning the final context dictionary with any new variables merged into it. The old calling convention is now deprecated, and will be phased out in Wagtail 1.11.

In most cases, the method will be calling get_context on the superclass, and can be updated by passing the new parent_context keyword argument to it:

class MyBlock ( Block ): def get_context ( self , value ): context = super ( MyBlock , self ) . get_context ( value ) ... return context

becomes:

class MyBlock ( Block ): def get_context ( self , value , parent_context = None ): context = super ( MyBlock , self ) . get_context ( value , parent_context = parent_context ) ... return context