From c50e05f6b978281e22a6d85eceab26c321ec4e0e Mon Sep 17 00:00:00 2001 From: benjaoming Date: Sun, 3 Feb 2013 14:30:30 +0100 Subject: [PATCH] Display a helping exception message when MPTT is failing --- wiki/views/mixins.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wiki/views/mixins.py b/wiki/views/mixins.py index b0d5cd8f..32653cbd 100644 --- a/wiki/views/mixins.py +++ b/wiki/views/mixins.py @@ -13,10 +13,13 @@ class ArticleMixin(TemplateResponseMixin): self.article = article self.children_slice = [] if settings.SHOW_MAX_CHILDREN > 0: - for child in self.article.get_children(max_num=settings.SHOW_MAX_CHILDREN+1, - articles__article__current_revision__deleted=False, - user_can_read=request.user): - self.children_slice.append(child) + try: + for child in self.article.get_children(max_num=settings.SHOW_MAX_CHILDREN+1, + articles__article__current_revision__deleted=False, + user_can_read=request.user): + self.children_slice.append(child) + except AttributeError, e: + raise Exception("Attribute error most likely caused by wrong MPTT version. Use 0.5.3+.\n\n" + str(e)) return super(ArticleMixin, self).dispatch(request, *args, **kwargs) def get_context_data(self, **kwargs): -- 2.45.2