From b1076b66a16a99e5e0318e10979fec88f42534ef Mon Sep 17 00:00:00 2001 From: Rui Manuel da Silva Martins Date: Mon, 25 May 2015 18:12:35 +0100 Subject: [PATCH] Prevent raising error in case of parent page url_path does not exists --- wagtail_modeltranslation/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wagtail_modeltranslation/models.py b/wagtail_modeltranslation/models.py index 8adceec..173b8fa 100644 --- a/wagtail_modeltranslation/models.py +++ b/wagtail_modeltranslation/models.py @@ -239,6 +239,11 @@ class TranslationMixin(object): tr_slug = getattr(self, 'slug_'+settings.LANGUAGE_CODE) parent_url_path = getattr(parent, 'url_path_'+lang[0]) + + if not parent_url_path: + parent_url_path = getattr(parent, 'url_path') + + setattr(self, 'url_path_'+lang[0], parent_url_path + tr_slug + '/') else: # a page without a parent is the tree root,