diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index 7346e3b9ba..322aa4695e 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -425,7 +425,15 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed # the ContentType.objects manager keeps a cache, so this should potentially # avoid a database lookup over doing self.content_type. I think. content_type = ContentType.objects.get_for_id(self.content_type_id) - if isinstance(self, content_type.model_class()): + model_class = content_type.model_class() + if model_class is None: + # Cannot locate a model class for this content type. This might happen + # if the codebase and database are out of sync (e.g. the model exists + # on a different git branch and we haven't rolled back migrations before + # switching branches); if so, the best we can do is return the page + # unchanged. + return self + elif isinstance(self, model_class): # self is already the an instance of the most specific class return self else: