Updated code for latest wagtail version