Wagtail 中的资源管理器不显示任何页面
Explorer in Wagtail does not show any pages
我有两个相同代码的实例(开发和生产),我发现这个问题只发生在生产中。我将两者都部署到了原始实例,这意味着在此之前没有安装 Wagtail。
Wagtail 管理员显示我没有页面。我确实有 2 页,即使我没有,也不应该有 "Welcome to Wagtail Page"(通常是,它在我的开发实例上)。此外,网站似乎缺少一部分内容。
这就是我所看到的,无论我创建了多少页面(我通过 URL 创建它们)
编辑:
这是日志中的完整堆栈跟踪
2017-04-21 10:27:08,898 exception 22370 ERROR Internal Server Error: /admin/pages/
Traceback (most recent call last):
File "/opt/..../venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 42, in inner
response = get_response(request)
File "/opt/..../venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/opt/..../venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/..../venv/lib/python3.5/site-packages/django/views/decorators/cache.py", line 43, in _cache_controlled
response = viewfunc(request, *args, **kw)
File "/opt/..../venv/lib/python3.5/site-packages/wagtail/wagtailadmin/decorators.py", line 24, in decorated_view
return view_func(request, *args, **kwargs)
File "/opt/..../venv/lib/python3.5/site-packages/wagtail/wagtailadmin/views/pages.py", line 104, in index
'do_paginate': do_paginate,
File "/opt/..../venv/lib/python3.5/site-packages/django/shortcuts.py", line 30, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader.py", line 68, in render_to_string
return template.render(context, request)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/backends/django.py", line 66, in render
return self.template.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 208, in render
return self._render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
bit = node.render_annotated(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render
return compiled_parent._render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
bit = node.render_annotated(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render
return compiled_parent._render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
bit = node.render_annotated(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render
return compiled_parent._render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
bit = node.render_annotated(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 70, in render
result = block.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
bit = node.render_annotated(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 70, in render
result = block.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render
return compiled_parent._render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
bit = node.render_annotated(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/defaulttags.py", line 314, in render
if match:
File "/opt/..../venv/lib/python3.5/site-packages/django/core/paginator.py", line 112, in __len__
return len(self.object_list)
File "/opt/..../venv/lib/python3.5/site-packages/django/db/models/query.py", line 238, in __len__
self._fetch_all()
File "/opt/..../venv/lib/python3.5/site-packages/django/db/models/query.py", line 1087, in _fetch_all
self._result_cache = list(self.iterator())
File "/opt/..../venv/lib/python3.5/site-packages/wagtail/wagtailcore/query.py", line 380, in specific_iterator
pages = model.objects.filter(pk__in=pks)
AttributeError: 'NoneType' object has no attribute 'objects'
经过进一步调查,我发现当您从项目中删除页面模型定义时会发生此错误,但该类型的页面仍然存在。 (Wagtail 应该 能够优雅地处理这种情况 - 事实上它不是一个错误,我很快就会提交一个问题...)
您可以通过 运行在 ./manage.py shell
命令行中输入以下几行来跟踪此问题:
from django.contrib.contenttypes.models import ContentType
[(ct.id, ct.app_label, ct.model) for ct in ContentType.objects.all() if ct.model_class() is None and ct.app_label != 'wagtailadmin']
希望这会产生如下结果:
[(2, u'home', u'homepage')]
显示缺失页面类型的内容类型 ID、应用标签和模型名称。
要让管理员重新工作,运行 以下行(确保将 2
替换为上面结果中的内容类型 ID):
from wagtail.wagtailcore.models import Page
Page.objects.filter(content_type_id=2).update(content_type=ContentType.objects.get(app_label='wagtailcore', model='page'))
这会将受影响的页面转换为 Wagtail 的基本 'Page' 类型(除 'title' 外没有其他内容字段)- 然后您可以继续删除此页面。
对我来说,@sagman 的解决方案只需稍作改动即可。发现如果在 Shell 中输入 wagtail.wagtailcore 但在 INSTALLED 中输入 wagtail.core 会出现 ModuleNotFoundError APPS,需要在Shell中输入from wagtail.core.models import Page而不是wagtail.wagtailcore.models import Page。其他一切都按照@gasman 的说明工作。
我有两个相同代码的实例(开发和生产),我发现这个问题只发生在生产中。我将两者都部署到了原始实例,这意味着在此之前没有安装 Wagtail。
Wagtail 管理员显示我没有页面。我确实有 2 页,即使我没有,也不应该有 "Welcome to Wagtail Page"(通常是,它在我的开发实例上)。此外,网站似乎缺少一部分内容。
这就是我所看到的,无论我创建了多少页面(我通过 URL 创建它们)
编辑: 这是日志中的完整堆栈跟踪
2017-04-21 10:27:08,898 exception 22370 ERROR Internal Server Error: /admin/pages/
Traceback (most recent call last):
File "/opt/..../venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 42, in inner
response = get_response(request)
File "/opt/..../venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/opt/..../venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/..../venv/lib/python3.5/site-packages/django/views/decorators/cache.py", line 43, in _cache_controlled
response = viewfunc(request, *args, **kw)
File "/opt/..../venv/lib/python3.5/site-packages/wagtail/wagtailadmin/decorators.py", line 24, in decorated_view
return view_func(request, *args, **kwargs)
File "/opt/..../venv/lib/python3.5/site-packages/wagtail/wagtailadmin/views/pages.py", line 104, in index
'do_paginate': do_paginate,
File "/opt/..../venv/lib/python3.5/site-packages/django/shortcuts.py", line 30, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader.py", line 68, in render_to_string
return template.render(context, request)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/backends/django.py", line 66, in render
return self.template.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 208, in render
return self._render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
bit = node.render_annotated(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render
return compiled_parent._render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
bit = node.render_annotated(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render
return compiled_parent._render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
bit = node.render_annotated(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render
return compiled_parent._render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
bit = node.render_annotated(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 70, in render
result = block.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
bit = node.render_annotated(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 70, in render
result = block.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render
return compiled_parent._render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 994, in render
bit = node.render_annotated(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
return self.render(context)
File "/opt/..../venv/lib/python3.5/site-packages/django/template/defaulttags.py", line 314, in render
if match:
File "/opt/..../venv/lib/python3.5/site-packages/django/core/paginator.py", line 112, in __len__
return len(self.object_list)
File "/opt/..../venv/lib/python3.5/site-packages/django/db/models/query.py", line 238, in __len__
self._fetch_all()
File "/opt/..../venv/lib/python3.5/site-packages/django/db/models/query.py", line 1087, in _fetch_all
self._result_cache = list(self.iterator())
File "/opt/..../venv/lib/python3.5/site-packages/wagtail/wagtailcore/query.py", line 380, in specific_iterator
pages = model.objects.filter(pk__in=pks)
AttributeError: 'NoneType' object has no attribute 'objects'
经过进一步调查,我发现当您从项目中删除页面模型定义时会发生此错误,但该类型的页面仍然存在。 (Wagtail 应该 能够优雅地处理这种情况 - 事实上它不是一个错误,我很快就会提交一个问题...)
您可以通过 运行在 ./manage.py shell
命令行中输入以下几行来跟踪此问题:
from django.contrib.contenttypes.models import ContentType
[(ct.id, ct.app_label, ct.model) for ct in ContentType.objects.all() if ct.model_class() is None and ct.app_label != 'wagtailadmin']
希望这会产生如下结果:
[(2, u'home', u'homepage')]
显示缺失页面类型的内容类型 ID、应用标签和模型名称。
要让管理员重新工作,运行 以下行(确保将 2
替换为上面结果中的内容类型 ID):
from wagtail.wagtailcore.models import Page
Page.objects.filter(content_type_id=2).update(content_type=ContentType.objects.get(app_label='wagtailcore', model='page'))
这会将受影响的页面转换为 Wagtail 的基本 'Page' 类型(除 'title' 外没有其他内容字段)- 然后您可以继续删除此页面。
对我来说,@sagman 的解决方案只需稍作改动即可。发现如果在 Shell 中输入 wagtail.wagtailcore 但在 INSTALLED 中输入 wagtail.core 会出现 ModuleNotFoundError APPS,需要在Shell中输入from wagtail.core.models import Page而不是wagtail.wagtailcore.models import Page。其他一切都按照@gasman 的说明工作。